svelte: Resetting custom store stops it from updating the DOM
Describe the bug
Calling store.set({}) stops the store clients from seeing store updates and stops the DOM from updating
To Reproduce
Please check this PR for the setup that leads to the issue - https://github.com/Rolandisimo/bs-bingo/pull/1
You can clone the repository and run it on the add-reset-button
Store is used in:
App.sveltebingo.ts
Steps
- Toggle any word block by clicking on it
- Keep some blocks higlighted
- Click reset button
- Try toggling word blocks
Expected behavior The DOM keeps reacting to the store update
Actual behavior

Notes
- The logging in the gif is done with
$: console.log($selectedWordsStore);
If this turns out to be not a bug, then the documentation needs to be updated and much more complex custom store examples need to be added. Currently the only examples are of primitive store values like numbers and strings.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (4 by maintainers)
@Rolandisimo we’re trying to prevent github issues becoming yet another forum for endless discussion which would be better carried out in a realtime chat. Please understand and respect this.
If you think there needs to be clarity in documentation then by all means raise it as an issue and open a PR to help other users, especially if you find the answer given vague - this is again because this is not intended as a help forum, but more of a clear, concise tracker for issues with Svelte.
Finally please don’t direct others to help you, Svelte and it’s support, maintenance, contributions, and documentation are provided as a voluntary, free, opt-in service. There should be no expectation of anything, and people will assist members of the community where they see fit.
We don’t want to have a
.get()directly on store instances be part of the store contract, because then every custom store would have to implement it, and there would be more ways for.get()and.subscribe()to become out of sync..get()on stores doesn’t provide you with anything that https://svelte.dev/docs#get doesn’t.Your REPL breaks because calling
set({})detaches the store value from thestatevariable. Separately callingstate = {}is also bad because it gets thestatevariable to a different empty object than the store value, and if one is mutated, the other will be unchanged.GitHub issues aren’t the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room.