How to reset the store to the default values? #165
Unanswered
StevenClontz
asked this question in
Q&A
Replies: 2 comments
-
One method: I exported constants for those initial values at https://github.com/StevenClontz/LetsSplitUpGang/blob/main/src/stores.ts and simply overwrote the stores using those values like this https://github.com/StevenClontz/LetsSplitUpGang/blob/main/src/components/ResetAppButton.svelte |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @StevenClontz! I think one way is to set the store back to it's initial value: const store = peristed('mykey', initialValue)
// reset
store.set(initialValue)
// or in a component
$store = initialValue If you want to reset the key in It might be worth adding a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to implement a "Reset app data" button that returns the store to the initial value used in creating the persisted store. Naively,
localstorage.clear()
is insufficient. :-) What's the idiomatic way to accomplish this?Beta Was this translation helpful? Give feedback.
All reactions