Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the keys within the modules #11

Open
rderimay opened this issue May 15, 2018 · 3 comments
Open

Define the keys within the modules #11

rderimay opened this issue May 15, 2018 · 3 comments

Comments

@rderimay
Copy link

rderimay commented May 15, 2018

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!

@maple3142
Copy link
Owner

maple3142 commented May 15, 2018

I think it is impossible until Vuex supports plugin for each module.
Vuex issue: vuejs/vuex#467

@rderimay
Copy link
Author

ok, thanks. Bad news :-)

@lucianodltec
Copy link

This can be done by registering vuejs-storage multiple times, one for each module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants