Unclear watchEffect example in the docs #7796
-
The official docs provides this example for
However, just a few paragraphs down there's a tip:
So in this example, the property appears after the first await so would it be tracked or not? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The tracking of object properties is based on property access, and its implementation is to proxy the get method through proxy. In the above example, |
Beta Was this translation helpful? Give feedback.
The tracking of object properties is based on property access, and its implementation is to proxy the get method through proxy. In the above example,
todoId
is accessed, thentodoId
will be collected as a dependency, anddata.value
is an assignment action, it does need to wait forawait
to be executed before it is assigned . The action of assignment only triggers the execution of dependent functions. So in this exampletodoId
will be collected, anddata.value
will be assigned and trigger the corresponding dependent function