How to clear a store?
From the docs, seems that setting a store's value explicitly to
undefined
will delete it from the store,
However, is there a way to clear them all in one go? If there are many keys, or the keys change, it's hard to ensure they're all getting deleted when they need to.5 Replies
I answered this here: https://discord.com/channels/722131463138705510/1173831851765411840/1174024744811634718
basically no straightforward way, but
setStore(Object.keys(store), undefined)
gets you thereAppreciate the answer even if the question is a dupe, it didn't show up in the search results before posting this one.
If useful, with TS would look like,
I do
setStore(reconcile({}))
for that use case
This is what the new doc seems to recommend
https://docs.solidjs.com/references/api-reference/stores/using-stores#updating-storesAmazing, thank you!
i didn't know you can do
['array', 'of', 'keys']
that's cool