probil / vue-socket.io-extended

:v::zap: Socket.io bindings for Vue.js and Vuex (inspired by Vue-Socket.io)
MIT License
628 stars 38 forks source link

NuxtJS with vuex #534

Open TheCherry opened 3 years ago

TheCherry commented 3 years ago

Greetings,

I don't get your system working with nuxtjs + vuex. If I use nuxtjs and make emits and subscriptions in a component, its work very well. But If I try to do it with the store, I have no results.

plugin file:

import Vue from 'vue';
import { io } from 'socket.io-client';
import VueSocketIOExt from 'vue-socket.io-extended';

const socket = io('http://localhost:8080');

export default ({ store }) => {
    Vue.use(VueSocketIOExt, socket, { actionPrefix: 'SOCKET_', store });
}

example store file (I tried many variants, not only this one)

export const state = () => ({
    list: []
})

export const mutations = {
    SOCKET_TOKEN(arg1, arg2){
        console.log("console 1")
    },
    SOCKET_HELLO(arg1, arg2) {
        console.log("console 2")
    },
    SOCKET_token(arg1, arg2) {
        console.log("console 3")
    }
}