Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

vuex-persistedstate does not follow vuex plugin guidelines #436

Open
jaitaiwan opened this issue Dec 7, 2021 · 2 comments
Open

vuex-persistedstate does not follow vuex plugin guidelines #436

jaitaiwan opened this issue Dec 7, 2021 · 2 comments

Comments

@jaitaiwan
Copy link

  • vuex-persistedstate version: 4.1.0
  • node version: 16.9.1
  • npm (or yarn) version: 3.0.2

Refer to vuejs/vuex#2046 (comment)

Effectively vuex-persistedstate modify's the store state within it's constructor and doesn't emit any mutations to the store thereby breaking the initial state.

As far as I can tell, the plugin will need a significant re-write to support this.

@robinvdvleuten
Copy link
Owner

@jaitaiwan thanks for notifying about this. I don't see any "official" guidelines, so could you maybe give a summary on how the plugin needs to be rewritten?

@jaitaiwan
Copy link
Author

Sorry, I should have linked it @robinvdvleuten, my bad.

According to https://vuex.vuejs.org/guide/plugins.html#committing-mutations-inside-plugins plugins should not directly mutate state at all but rather should rely on mutations. From what I could tell of the plugin it's missing any concept of a mutation and emitting changes to the store (I did find it difficult to tell what branches have active development, but after checking 3 of them that was my conclusion).

I've just opened up a new PR to vuex-persist to fix some of their issue with vuex 4; but theirs is because of the use of Vue.set. They already have documentation around enabling "strict mode" and adding a mutation from the plugin.

Does that help at all? I haven't had much more time to delve into vuex-persistedstate beyond my initial comments above and in the vuex ticket.

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

No branches or pull requests

2 participants