vuejs-storage
vuejs-storage copied to clipboard
Define the keys within the modules
This is not a bug. It is a request / question.
Let say you have a standard vuex structure with a few modules
export default new Vuex.Store({
modules: {
moduleA,
moduleB,
},
plugins: [
VueJsStorage({
keys: [
'moduleA.all'
],
namespace: 'test',
}),
],
})
with moduleA:
const state = {
all: {},
}
export default {
state,
getters,
mutations,
actions,
}
This works perfectly, as intended. For me thought, it breaks the modularity of the modules, as the vuex parent has to know about the name of the keys to be persisted with its submodules.
It would be more modular if the sub modules could define their permitted keys themselves.
Is there a way to reach this?
Many thanks!
I think it is impossible until Vuex supports plugin for each module. Vuex issue: https://github.com/vuejs/vuex/issues/467
ok, thanks. Bad news :-)
This can be done by registering vuejs-storage multiple times, one for each module.