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
Reactive statements/blocks don't seem to be "recursive" (so to speak).
When a reactive block checks for a condition to apply and the condition changes within the reactive block itself, the condition is not rechecked.
At component's creation, the reactive block is evaluated and count is assigned itself plus 1.
But then after this assignment it doesn't go on checking if count is less than 10 and increment it accordingly (which is what I was expecting).
Assigning to count outside the block through the button makes the block run again (and count is added twice, one because of the handler and one because of the block).
I don't know if this is the expected behavior (that's why I'm writing this as a question and not as an issue), but I would have expected (and wanted) the reactive block to be evaluated any time that count changes, be it outside the block or within it.
Maybe a variable is not deemed a dependency of a block if it's also among its performed assignments? (e.g. $: count += 1 doesn't work either, while I would have expected it to stack overflow).
Thanks.
The text was updated successfully, but these errors were encountered:
This is the intended behavior, although it is indeed a TODO to find somewhere to document this better. The short answer is that synchronous changes to variables during reactive blocks do not trigger another a run through the reactive blocks afterwards. It's not precisely the question you're asking here, but I talk a bit about what's going on in this comment.
Your explanation about synchronous code in reactive blocks matches what I found on a stackoverflow question about using setTimeout() for another use case. Putting it here makes the block "loop" as I expected, too.
Yes, I think that currently the biggest drawback for me in using this technology is lack of detailed documentation (both the tutorial and API docs are fine, but we're programmers and rather than the "do-this-to-have-that" sort of bits I'd like to know exactly what happens when I write code).
Thank you for the answer.
Reactive statements/blocks don't seem to be "recursive" (so to speak).
When a reactive block checks for a condition to apply and the condition changes within the reactive block itself, the condition is not rechecked.
See this REPL:
At component's creation, the reactive block is evaluated and
count
is assigned itself plus 1.But then after this assignment it doesn't go on checking if
count
is less than 10 and increment it accordingly (which is what I was expecting).Assigning to
count
outside the block through the button makes the block run again (andcount
is added twice, one because of the handler and one because of the block).I don't know if this is the expected behavior (that's why I'm writing this as a question and not as an issue), but I would have expected (and wanted) the reactive block to be evaluated any time that
count
changes, be it outside the block or within it.Maybe a variable is not deemed a dependency of a block if it's also among its performed assignments? (e.g.
$: count += 1
doesn't work either, while I would have expected it to stack overflow).Thanks.
The text was updated successfully, but these errors were encountered: