watch(..., { flush: "pre" })
behaves like "sync"
#5721
Labels
❗ p4-important
Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf.
scope: reactivity
Version
3.2.33
Reproduction link
sfc.vuejs.org/
Steps to reproduce
What is expected?
Output:
What is actually happening?
Output (only difference is the
pre
lines):Unfortunately, the API docs on vuejs.org don't define the behavior of
"pre"
,"sync"
and"post"
(also not here). Strangely, I found more exhaustive documentation here on w3cub.com (Vue 3-related), that says:"sync"
when"pre"
was passed and calls the callback immediately and synchronously, asconsole.log()
calls prove.The output for
"pre"
, as listed before, is expected to be diffrent to the current actual output for the following reasons:a
mutation (a.value++
) should be reserved for"sync"
.a
orb
is, in my opinion and according to my understanding, also in the realm of"sync"
. I'm trying to use"pre"
to watch multiple sources as a whole, sources that are often, but not always, mutated together and where a watcher-callback-run after the mutation of just one source might catch an inconsistent state, which leads to undefined behavior.watch()
also isn't defined enough when there are multiple watch sources. Without knowing specifics about other use cases, it's conceivable that both logical linkings can be desirable. The default behavior should be clearly communicated and, if need be, an additional option should be added to get the other type of logical linking of the sources.The text was updated successfully, but these errors were encountered: