If your reactive side effects aren't properly timed in a Vue app, you'll see very confusing behavior.
To fully understand Vue effect timing, you'd have to learn about microtasks in browser-based JavaScript. That said, a deep understanding of microtasks and of the browser event loop is really only practical for framework authors—it's not practical knowledge for framework users.
Instead of trying to learn how Vue effect timing actually works under the hood, try learning the following:
- Simplified versions of effect timing concepts
- Some opinionated guidelines on how to use the two effect timing tools at your disposal in Vue 3: the
flush
option forwatch
andwatchEffect
, andnextTick
.