Skip to content

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

Discussion options

You must be logged in to vote

In line 341, it has been determined that the current reactiveEffect is' Dirty ', indicating that the data must have changed.

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. when deep: true is set).

The second if-check is checking weither or not to run the callback.

Demo Playground

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@catpigdog
Comment options

@catpigdog
Comment options

@catpigdog
Comment options

Answer selected by LinusBorg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants