I have taken this from Svelte docs
It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are assigned to and used within the block itself, not in any functions called by them. This means that yDependent will not be updated when x is updated in the following example:
<script> let x = 0; let y = 0; /** @param {number} value */ function setY(value) { y = value; } $: yDependent = y; $: setY(x);</script>
Moving the line $: yDependent = y below $: setY(x) will cause yDependent to be updated when x is updated.
Refer the Svelte components section in this link https://svelte.dev/docs/svelte-components
Can someone explain me in detail what the docs is trying to say.
In the first case when x is changed setY(x) is triggered, which leads to y being changed but yDependent wont change because I understand that compiler will only look at the variables in the reactive blocks and not inside functions the block is calling.
The same must be true for 2nd case also right ?
I tried both the case and I see that in the first case yDependent stays a constant when x is changing. In the second case yDependent changes when x changes.