Open bashlakov opened 5 years ago
Hey @bashlakov, Have you found any solution?
just like this?
import Vuex from 'vuex'
import Vue from 'vue'
const createStore = () => {
return new Vuex.Store({
state : {
socket: {
isConnected: false,
},
bus: new Vue({
notifications: {
showSomething: {
title: 'Something happened',
message: 'See console for details',
type: 'error'
}
}
})
},
mutations: {
SOCKET_ONOPEN (state, event) {
state.socket.isConnected = true
},
SOCKET_ONCLOSE (state, event) {
state.socket.isConnected = false
},
SOCKET_ONMESSAGE (state, message) {
console.log(message);
this.state.bus. showSomething();
},
}
})
}
export default createStore
Hi! Is there a way to emit notification from vuex mutation? I'm trying to show notification on websocket message received event. I'm using vue-native-websocket and nuxt, so my store's index.js looks like that:
How can I fire notification from SOCKET_ONMESSAGE mutation?