Skip to content

Good way to update local storage on state change? #123

Answered by lostpebble
FaultyFunctions asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

You could just use subscribe as you described, over the entire store's state. Then whenever any value inside the store updates- the subscribe callback will be called and you can update local state with the new values. The subscribe function takes any value from your store, but that value can be calculated however you like from the entire store. You could also just return an entirely new object of just the keys and values you would like to store in local storage.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@FaultyFunctions
Comment options

Answer selected by FaultyFunctions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants