How to reset the store to the default values? #165
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.
-
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.
-
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