Description
Describe the bug
When you bind:
values from a store inside #each
it will call set
for every iterated item for no reason. I'm using this pattern a lot where I have a store (that is backed by sessionStorage
, synced via BroadcastChannel
and persisted via fetch()
). I love how I can pass values from inside a store around, then child components can update them and everything magically works across windows and is persisted between app restarts (Electron).
But I've just ran into an edge case where I'm seeing a lot of completely unnecessary calls to set
, causing pointless disk and network I/O. Since this is happening inside #each
there can easily be dozens of set
for each item I bind to.
To Reproduce
I wrapped the set
method so it logs every call. When you open this REPL you'll see two set
calls for no reason.
https://svelte.dev/repl/1e967d0310c3428989dde2ec1bf70087?version=3.38.2
Expected behavior
There is no reason to call set
when there was no change.
Information about your Svelte project:
REPL 3.38.2
Severity
Medium. I'll probably have to workaround this by sprinkling some fast-deep-equal
over my stores.