Closed docmattman closed 3 years ago
@docmattman Did you ever find a solution to this? I am also curious about how to do this.
@docmattman Hi,
I don't know why I never saw this issue and going through my emails, I noticed I hadn't received any (which is very strange)
Anyhow, in my personal opinion, if you're trying to do it for a certain route, I recommend using the fetch
block to keep the store in sync with the persisted data the user has stored.
If you want to do it for your entire Nuxt.js application, I would move this logic to my nuxtServerInit
block and dispatch a function/functions that update your store accordingly. You can read more about nuxtServerInit
here : https://nuxtjs.org/guide/vuex-store/#the-nuxtserverinit-action
I hope this answers your question.
Are there any docs or example usages? I have a couple of store modules, it'd be nice to use this to store persistent data. I'm not sure how to implement the "initialState" though, since the
state
doesn't havethis.$storage
available. Trying to do something like this in my store:Am I going about this the wrong way? Should I not try to use the universal storage inside my store? Should I just use
this.$storage.syncUniversal('project', {})
inside of a component instead and not even haveproject
in my store? Just looking for a little guidance on basic usage.