cs01/stator

State resets to intialized value on page refresh

Opened this issue · 3 comments

Hey, I've found this package to be really useful in storing profile info from my id_token into my application state, eliminating the need to constantly decode the token or setup Redux for a fairly simple use-case.

But when my page is refreshed, all my states are reset to the their initialized values. Is there any way to make them persist?

cs01 commented

I think what you are looking for is localStorage. You could add some hooks manually to save the store with store.get() before the page closes. Then when the page is opened again, you could try to read the store from local storage and set it as the initial data when initializing the store. I could also add an option to the API to do this, but not sure when I could get to it.

How about showing an example on in the Readme?

Could help a lot of newcomers.

Update: Oh my bad, I just finished the docs. and you actually explain that. My bad!

Btw, awesome library you've made.

cs01 commented

I am working on adding some built-in functions to stator to make this easier. Stay tuned!