vuex-persistedstate version: 2.5.4node version: v8.11.1npm (or yarn) version: 5.6.0Relevant code or config
Problem description:
I am using vuex-persistedstate with localStorage to store the data.
I am trying solve the problem where when two tabs opened, one's storage is updated, say auth token refreshed, the other tab still keeps the old state, which means it gets the old token. I guess it is cached and not load data from localStorage.
Currently I am using window.addEventListener('storage', (e) => { }) to observe the changes and I am able to compare two tokens, if tokens are different, I manually mutate the state to the new one.
But this is not the ideal solution for me. It would be good that I can somehow force the vuex to load the data from localStroage to the state. How can I do that?
Any solution to this? I'm having the same problem...
Same here
Same issue. I've also been using onstorage to update vuex but on a big application this can get really messy.
I made a small plugin for Vuex who updates automatically the state saved in localStorage. If you want you can have a look.
@gabrielmbmb with the link it's better, isn't ?
https://github.com/gabrielmbmb/vuex-multi-tab-state
You can just use eventlisteners for such usecases.
Most helpful comment
Any solution to this? I'm having the same problem...