vuejs / vuejs/docs

`watch()` `flush` option values `"pre"`/`"post"`/`"sync"` not defined

Open
#1,668 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Vue
Stars
3.2k
Forks
5k
Avg merge
14d 17h
Merged PRs (30d)
1

Description

Unfortunately, the docs miss exhaustive descriptions of these options on the following pages:

Strangely, I found more exhaustive Vue 3-related documentation here on w3cub.com that explains the flush option in detail. How does a third-party website have more documentation than the official website of the product? 😶 Where does it even come from?


I want to use { flush: "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. (Related bug just fixed.)

It would be good if the AND/OR behavior of watch() on multiple sources was also clarified for each flush option value. I guess "sync" can be described as linking with OR; "pre" and "post" as linking with AND in the context of one update tick.

According to w3cub.com, "pre" "specifies that the callback should be invoked before rendering." Could it be further clarified what that means in a context like the following? There are multiple composables, each watch()ing its inputs and generating/mutating reactive outputs in the callback that are the inputs of the next composable, until finally a component is fed by the last composable's outputs.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reactivity-core and component-instance watch API pages named in the issue, then review the linked core issue for the relevant behavior. Update the documentation to define the pre, post, and sync flush values and clarify multiple-source behavior only where the project behavior supports it.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.