Skip to content

fix: prevent reactive statement reruns #10736

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

Merged
merged 1 commit into from
Mar 10, 2024
Merged

Conversation

dummdidumm
Copy link
Member

  • run reactive statements only once per tick, even when they have indirect cyclic dependencies. Made possible by adding an array to the component context, which is filled with identifiers of the reactive statements, and which is cleared after all have run. Reactive statements rerunning before that will bail early if they detect they're still in the list
  • part of the solution is to run all reactive statements, and then all render effects, which also fixes Svelte 5 changes the update order of $: and {#key} in Svelte 4 Components #10597

FYI @Rich-Harris - okay to merge? This touches some of the stuff you're refactoring

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

- run reactive statements only once per tick, even when they have indirect cyclic dependencies. Made possible by adding an array to the component context, which is filled with identifiers of the reactive statements, and which is cleared after all have run. Reactive statements rerunning before that will bail early if they detect they're still in the list
- part of the solution is to run all reactive statements, and then all render effects, which also fixes #10597
Copy link

changeset-bot bot commented Mar 9, 2024

🦋 Changeset detected

Latest commit: 5583399

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

yeah, i'll fix the conflicts. this is still in draft though, is it ready? approved if so

@dummdidumm dummdidumm marked this pull request as ready for review March 10, 2024 18:54
@dummdidumm
Copy link
Member Author

Yeah it's ready, just put it in draft Mode to prevent accidental merges before you respond

@dummdidumm dummdidumm merged commit 74474fe into main Mar 10, 2024
@dummdidumm dummdidumm deleted the reactive-statement-tweaks branch March 10, 2024 18:55
@dummdidumm dummdidumm mentioned this pull request Mar 12, 2024
5 tasks
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 this pull request may close these issues.

Svelte 5 changes the update order of $: and {#key} in Svelte 4 Components
2 participants