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
Not sure if this is a bug but it is certainly something I didn't expect: reactive statements' execution depend on the order of declaration.
Here's an example which you could try out in the REPL that I provided:
<script>
let value = 0
let loading = true
function setValue () {
value = 5
loading = false
}
// $: if (loading) setValue() // works here
$: squared = value ** 2
$: if (loading) setValue() // doesn't work here
</script>
Desired output: {value ** 2} <!-- 25 -->
<br />
Actual output: {squared} <!-- 0 -->
Here Actual output will be 0 and not 25.
If I move the reactive if statement on top of the squared one, however, Actual output will be 25.
$: if (loading) setValue() // works here
$: squared = value ** 2
Describe the bug
Not sure if this is a bug but it is certainly something I didn't expect: reactive statements' execution depend on the order of declaration.
Here's an example which you could try out in the REPL that I provided:
Here
Actual output
will be0
and not25
.If I move the reactive if statement on top of the
squared
one, however,Actual output
will be25
.Why is that and is this expected behavior?
Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: