davestewart / vuex-pathify

Vue / Vuex plugin providing a unified path syntax to Vuex stores
https://davestewart.github.io/vuex-pathify
MIT License
1.37k stars 57 forks source link

Does vuex-pathify work with vuex-persist & vuex modules out of the box? #119

Closed dimavolo closed 3 years ago

dimavolo commented 3 years ago

I've initialized vuex-persist in the standard way:

const vuexLocal = new VuexPersistence({
  storage: window.localStorage,
})

I have two typical vuex modules: [user, nav]

I'm finding that instead of persisting user.user.firstName, it is persisting it as user.firstName (i.e. one level up).

Does pathify normally work with vuex-persist and typical vuex modules out of the box, or is there some configuration required?

Thanks!

Update I found that if I change user.user to a unique sub-key name, like user.userData, then it all works as expected. Spoke too soon.

davestewart commented 3 years ago

Hey.

Should do, but this sounds like an issue with Vuex Persist rather than Pathify.

All Pathify does is the wiring to your store, along with some clever "reaching into" properties if you use make.mutations() and sub@properties.

If you remove Vuex Pathify does the other library magically work?

davestewart commented 3 years ago

Closing because no reply.

vesper8 commented 1 year ago

I found some really weird and abnormal behaviour when using vuex-pathify with vuex-persistedstate.

For example if I push something into an array like this this.myPathifyKey.push(someElement) then it will be registered (persisted) by vuex-persistedstate only if it's done in some places, such as in a mounted hook of a component, while if I do the exact same thing inside an event listener for example, then it will not be persisted.

But, if I do this instead this.$store.set('pathifyModule/myPathifyKey', ...myArray)

Then it will be persisted ? Go figure.. could not understand why it's failing in the first instance.