Open JH-Eric-Yang opened 1 year ago
Hi, I tired to call a mutation function in the vuex's store inside a socket event listener. It looks something like this
import { createStore } from "vuex"; export default createStore({ state() { return { message: "default message", }; }, mutations: { SOCKET_updateMessage(state, message) { console.log("SOCKET_updateMessage: message:", message); state.message = message; this.updateMessage(message); }, updateMessage(message) { console.log(message) }, }, });
It will work but I notice that it will recreate a new socket instance. The client will create and communicate with the server with the new socket instance (with different socket.id). I wonder why this is happening. Thank you.
Hi, I tired to call a mutation function in the vuex's store inside a socket event listener. It looks something like this
It will work but I notice that it will recreate a new socket instance. The client will create and communicate with the server with the new socket instance (with different socket.id). I wonder why this is happening. Thank you.