Hi,
In my project's folder structure I splitted my Vuex actions (and also mutations, getters and state) into separate files, like suggested here.
Here is an example of an action.js file:
export const saveUserLog = ({ commit, rootState }, data) => { data.user = rootState.globalModule.userConnected._id commit('addUserLogToTempMemory', data) this.$socket.emit('saveUserLog', data) // this doesn't work }
How can I access to the $socket instance from within my action ?
I tried
export const saveUserLog = ({ commit, rootState, Vue }, data) => { // adding Vue here data.user = rootState.globalModule.userConnected._id commit('addUserLogToTempMemory', data) Vue.$socket.emit('saveUserLog', data) // to access from here }
and like suggested in this post
export const saveUserLog = ({ commit, rootState }, data) => { data.user = rootState.globalModule.userConnected._id commit('addUserLogToTempMemory', data) this._vm.$socket.emit('saveUserLog', data) // doesn't work }
Can you help me?
Thanks
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4