-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Watch not triggered by changes during rendering #2730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like it by design. doc |
@Asv1 I don't see anything in the docs to suggest that this is by design. Triggering a |
With template refs you always must use flush post because refs assigned after rendering. |
Absolutely, and I don't think there is anything awkward in triggering a To me, whether a watch effect should be executed is the definition/contract of However, when and in what order effects are actually executed is an implementation detail. It is totally fine for the scheduler to queue an effect to an later (post or next pre) stage, but it still needs to execute the effect eventually.
I don't think the document is suggesting it is the golden rule for template ref watchers to always be post flush. Without |
I think this will be fixed by b57e995, which is available in 3.1.0-beta.5. |
Fixed in b57e995 |
in some cases useTitle doesn't work . it has to work in nextick https://codepen.io/yjl626/pen/rNyKVZW vuejs/core#2730 set watch option as flush: 'post' can fixed it I think it's a reliable option in this function
Version
3.0.4
Reproduction link
Steps to reproduce
I've provided two examples but I believe they're both effectively the same problem. In both cases you just need to click the button and then check the logging.
Notice that the logging from the
watch
gets behind. The new value isn't logged until the following button click.The first example uses
ref
attributes to update a reactiveref
. The second example uses anupdated
hook to achieve a similar effect.The workaround in both cases is to set
flush: 'post'
. However, that shouldn't be necessary. Any watchers withflush: 'pre'
that are still in the queue at the end of rendering should be processed immediately. I haven't checked the code but it may just be a case of going through another rendering cycle when there are outstanding watchers rather than specifically flushing the pre-watchers.What is expected?
All remaining watchers should be called by the time the rendering loop completes.
What is actually happening?
The watcher isn't called until the next time rendering is triggered.
The text was updated successfully, but these errors were encountered: