You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the Svelte docs, the callbacks of writable store subscriptions get called on these scenarios:
writable value changes
when first subscriber subscribes
However, when we bind a store value to a component, the callbacks get called whenever the component is created, even when the component is not a first subscription to the store.
The text was updated successfully, but these errors were encountered:
pavish
changed the title
Binding a store value to a component calls all the callbacks of all of store's subscribers when the component is created
Binding store value to a component evokes all callbacks of all of store's subscribers when the component is created
Mar 2, 2022
Describe the bug
Based on the Svelte docs, the callbacks of writable store subscriptions get called on these scenarios:
However, when we bind a store value to a component, the callbacks get called whenever the component is created, even when the component is not a first subscription to the store.
Reproduction
REPL Link: https://svelte.dev/repl/abb6864f83cc4b7f9a3e84cae74e8dad?version=3.46.4
When the REPL is opened, in the output console, you can notice the two logs:
Try clicking on the 'Toggle' button, you can notice that the text
names changed
gets logged wheneverComponent
is shown.If we remove
bind:names
and passnames={$names}
, it does not happen.Logs
No response
System Info
System: OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa) CPU: (4) arm64 unknown Memory: 188.52 MB / 1.94 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.19.0 - /usr/bin/node npm: 6.14.16 - /usr/bin/npm npmPackages: svelte: ^3.42.4 => 3.42.4
Severity
annoyance
The text was updated successfully, but these errors were encountered: