vue-socket.io-extended: Error while using the library with Vuex in Quasar App
Mutations are called when used with Store
My code looks like this…
[In App.vue]
import VueSocketio from 'vue-socket.io-extended'
import io from 'socket.io-client'
import store from './store'
Vue.use(VueSocketio, io(`http://${window.location.hostname}`), { store });
My mutation is like this in my store’s mutations
SOCKET_message (state, data) {
console.log(data)
}
From the server, we are emitting (‘message’, data) Please be noted that I am using Quasar and initializing it in App.vue. Works fine with components but not with Vuex store.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 27 (13 by maintainers)
I’ve just checked quasar project a little bit. And there is not main app entry point. So my suggestion would be to wrap plugin registration and call it during store init.
E.g.:
Then
I’ve just tried it on my local machine and it works just fine!
Can you check that @KodeStar and/or @sandeeppsmys ?
I was facing the same issue but using NuxtJs and I found that the parameter
storein the plugin file needs the{}:export default (store) => {change toexport default ({ store }) => {plugins/vue-socket.js
Hope it helps
Thanks probil… its working for me too. Appreciate your efforts and enthusiasm in closing the issue.
I think it may not like my store, I’m doing the following in router/index.js:
store/index.js looks like:
My store/terminals/mutations.js looks like:
I’ve also notice the following pop up in the console:
If I remove the store parts and use
sockets: {}directly on the component that works