Skip to content
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

How use Dynamic Listeners if use Vuex? #168

Closed
NordBee opened this issue Nov 26, 2018 · 2 comments
Closed

How use Dynamic Listeners if use Vuex? #168

NordBee opened this issue Nov 26, 2018 · 2 comments
Assignees
Labels

Comments

@NordBee
Copy link

NordBee commented Nov 26, 2018

Hello

How use Dynamic Listeners in app if use Vuex?

main.js
Vue.use(new VueSocketIO({ debug: true, connection: 'http://localhost:8888', vuex: { store, actionPrefix: 'socket_', mutationPrefix: 'SOCKET_' } }))

App.js
created () { this.sockets.subscribe('EVENT_NAME', (data) => { this.msg = data.message; }); }

[Vue warn]: Error in created hook: "TypeError: this.sockets is undefined"

If I use this.$socket, I see the same problem

@MetinSeylan
Copy link
Owner

hello @neonkaafi
plugin mixin, using created method for setting variables, you need to use beforeMount or mounted hooks

@NordBee
Copy link
Author

NordBee commented Nov 26, 2018

variable this.sockets don't have in beforeMount or mounted
because block if(this.$options.sockets) in mixin.js doesn't work

MetinSeylan added a commit that referenced this issue Nov 26, 2018
@MetinSeylan MetinSeylan self-assigned this Nov 27, 2018
topstack1226 added a commit to topstack1226/vuex that referenced this issue Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants