Skip to content
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

Order of reactive statements influences behavior in unexpected ways. #9101

Closed
c00 opened this issue Aug 13, 2023 · 1 comment
Closed

Order of reactive statements influences behavior in unexpected ways. #9101

c00 opened this issue Aug 13, 2023 · 1 comment

Comments

@c00
Copy link

c00 commented Aug 13, 2023

Describe the bug

Some reactive statements do not get triggered based on the order in which you write them:

$: if (val1) step1();
$: if (val2) step2();

If step1 updates val2, then that will trigger step2. That's expected.

However, if we switch the lines around to this:

$: if (val2) step2();
$: if (val1) step1();

Now, if step1 updates val2, then step2 will not be triggered.

It seems wrong that the order of this should have an effect on the outcome.

Reproduction

Repl

Steps to repro:

  1. click "Set value". Confirm that what you're seeing is expected. (The button sets val1, the step1 function sets val2, and the step2 function sets the output variable.
  2. Switch around line 9 and 10
  3. click "set value" again.

You can see in the console that val2 is still updated, but it not triggering step2. So the output is not updated.

Logs

No response

System Info

System:
    OS: Linux 6.2 Fedora Linux 36 (KDE Plasma)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 16.65 GB / 31.05 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 18.13.0 - ~/.asdf/installs/nodejs/18.13.0/bin/node
    npm: 8.19.3 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.6.9 - ~/.asdf/shims/pnpm
  Browsers:
    Brave Browser: 115.1.56.20

Severity

annoyance

@Conduitry
Copy link
Member

This is, for now, the intended behavior. See #5848. This is one of the areas we're planning to improve in Svelte 5, with an improved reactivity model.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2023
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

No branches or pull requests

2 participants