Skip to content

Binding to store value properties causes addition change per binding #5555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
techniq opened this issue Oct 21, 2020 · 11 comments · Fixed by #5890
Closed

Binding to store value properties causes addition change per binding #5555

techniq opened this issue Oct 21, 2020 · 11 comments · Fixed by #5890

Comments

@techniq
Copy link

techniq commented Oct 21, 2020

Describe the bug
When binding to a property of a store value, the value is updated / changed (subscribe called) for each bind statement, instead of just once for the initialization.

To Reproduce
REPL: https://svelte.dev/repl/83c80ca45be54486ae7fd15827660280?version=3.29.0

image

In the REPL, I would expect "pagination changed!" to be logged once when initialized, but it is being logged 3 times (2 additional times due to each bind:).

After the initial 3, only a single subscribe is called when changing anything on the store, as expected.

Expected behavior
I would expect a single call to subscribe on initialization, instead of 1 + (number of `bind:` properties)

Information about your Svelte project:

  • Svelte version: 3.29.0

Severity
In my application, this is causing all my HTTP requests to fire multiple times on init due to the changing store value, which makes this a rather significant issue for my project.

@xpuu
Copy link

xpuu commented Nov 19, 2020

This actually seems to be a pretty annoying bug. It doesn't apply only to stores. Binding all complex structures (objects, arrays) fires another extra update. Here's a link to my simplified REPL.

https://svelte.dev/repl/2bbb8d98fc8a49398d269dff0eb9843b?version=3.29.7

@techniq If you may, please update the bug title to something more straightforward, so as it gets more attention.

@Conduitry
Copy link
Member

This should be fixed now in 3.32.2 - https://svelte.dev/repl/83c80ca45be54486ae7fd15827660280?version=3.32.2

@xpuu
Copy link

xpuu commented Feb 8, 2021

I can confirm the fix. Many thanks! <3

@techniq
Copy link
Author

techniq commented Feb 8, 2021

Confirmed as well. Thanks @pushkine and @Conduitry!

@eahrold
Copy link

eahrold commented Jun 25, 2021

I believe a variation of this bug may still exists.

https://svelte.dev/repl/894cc9ff89634c81b83b3b4807326704?version=3.38.3

eahrold added a commit to OpenDDS/opendds-performance-dashboard that referenced this issue Jun 25, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
…ests

- Related to sveltejs/svelte#5555
@talentedandrew
Copy link

talentedandrew commented Jul 6, 2021

This should be fixed now in 3.32.2 - https://svelte.dev/repl/83c80ca45be54486ae7fd15827660280?version=3.32.2

Why does it trigger if I put it in the OnMount ? Shouldn't it trigger on changes, instead on initialisation ?

@frederikhors
Copy link

I think this is still not fixed: #6590

@gyurielf
Copy link

I believe a variation of this bug may still exists.

https://svelte.dev/repl/894cc9ff89634c81b83b3b4807326704?version=3.38.3

Yep I can confirm. It is still actual!

@pushkine
Copy link
Contributor

This issue was about bind:foo={object.property} where the property is a primitive, it is fixed.
Your issue has to do with bind:foo={object} which will never be fixed

@xpuu
Copy link

xpuu commented Jan 18, 2022

@pushkine Hi, can you elaborate a bit more on why it will be never fixed? I traced this problem up to this piece of code here and I honestly don't understand the greater logic behind this. #4265 (comment)

@Mrbeyond
Copy link

This bug is not fixed. It's really frustrating...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants