-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provide useSocket() function #520
base: alpha
Are you sure you want to change the base?
Conversation
This can be used in Vue's setup() function to inject the socket instance where $socket is not available: setup() { const socket = useSocket() }
The plugin now provides a default and named exports. So the tests now must explicitly test the default export.
Codecov Report
@@ Coverage Diff @@
## alpha #520 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 10 +1
Lines 124 131 +7
Branches 20 20
=========================================
+ Hits 124 131 +7
Continue to review full report at Codecov.
|
I'm going to add another composable:
...so you might want to wait before pulling |
onSocketEvent() is now working too and I have also added this to the README.md. |
Wow! That looks nice. 👍 Will check it on weekend and merge FYI I am thinking about sunsetting the BTW, you don't have to commit |
Sorry, missed that dist slipped in with the last commit. I've fixed it. Might be a good idea to add dist to |
This will subscribe to a socket.io event before the component is mounted and will unsubscribe before the component is unmounted. Usage: setup() { onSocketEvent('my-event', (data) => { ... }) }
Ok - I've added dist to .gitignore so I can't make the same mistake again. |
Mmm... it still doesn't work like it should. In my little toy project unsubscribing fails, because |
@e-tobi Any updates on this? I'll try to take a look at BTW thanks for spotting |
@e-tobi what's the best way for me to try out your PR? I can't find it in the 5.0.0-alpha.4 |
Is there any movement on this? |
This can be used in Vue's setup() function to inject the socket instance
where $socket is not available:
setup() {
const socket = useSocket()
}
Currently this breaks some tests - I will look into this later.