Why is it necessary to determine variables such as forceTrigger in the doWatch function when it has already been determined that the current ReactiveEffect is' Dirty '? #10550
Answered
by
LinusBorg
catpigdog
asked this question in
Help/Questions
-
Beta Was this translation helpful? Give feedback.
Answered by
LinusBorg
Mar 20, 2024
Replies: 1 comment 3 replies
-
The effect being dirty means that one or more of the effect's reactive dependencies changed. That does not necessarily mean that the effect's result itself will change. And in the case of The second if-check is checking weither or not to run the callback. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
LinusBorg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The effect being dirty means that one or more of the effect's reactive dependencies changed. That does not necessarily mean that the effect's result itself will change.
And in the case of
watch
, the first argument is the effect, the second argument is the callback (cb
) - and we only want to run the callback if the effect's return value actually changed (or we need to run it regardless, i.e. whendeep: true
is set).The second if-check is checking weither or not to run the callback.
Demo Playground