Since the "Classic" store mode is being deprecated, I'm a little unclear as to the best way to integrate plugins that made expressly for the store.
My example is vuex-cache
: https://github.com/superwf/vuex-cache
It uses a syntax that loads a plugin directly into the store instance like so:
import Vuex from 'vuex'
import vuexCache from 'vuex-cache'
const store = new Vuex.Store({
state: {
...
},
plugins: [vuexCache],
mutations: {
...
},
actions: {
...
}
})
store.cache.dispatch('LIST')
Since we don't have a hook into Vuex.Store in Nuxt since it utilizes the directory hook, I'd like to see some way to connect a store plugin to Nuxt's instance of the store.
Perhaps a connection could be made in the index.js under the /store directory, or perhaps it's something that would have to be declared from within the nuxt.config?
This feature already exists. Just export an array named plugins containing your vuex plugins that you want to apply to the current module.
So to apply a plugin to the vuex root module you would do the following:
store/index.js:
import myPlugin from „my-plugin“
export const plugins = [ myPlugin ]
// export const mutations = { ... }
// export const actions = { ... }
Most helpful comment
This feature already exists. Just export an array named plugins containing your vuex plugins that you want to apply to the current module.
So to apply a plugin to the vuex root module you would do the following:
store/index.js: