Skip to content

Commit 93d4aa6

Browse files
Add a note about flush: 'sync', with links from elsewhere (#1895)
1 parent 9a6021d commit 93d4aa6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/api/component-instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Imperative API for creating watchers.
218218
219219
- **`immediate`**: trigger the callback immediately on watcher creation. Old value will be `undefined` on the first call.
220220
- **`deep`**: force deep traversal of the source if it is an object, so that the callback fires on deep mutations. See [Deep Watchers](/guide/essentials/watchers.html#deep-watchers).
221-
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing).
221+
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing) and [`watchEffect()`](/api/reactivity-core.html#watcheffect).
222222
- **`onTrack / onTrigger`**: debug the watcher's dependencies. See [Watcher Debugging](/guide/extras/reactivity-in-depth.html#watcher-debugging).
223223
224224
- **Example**

src/api/options-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ Declare watch callbacks to be invoked on data change.
291291
292292
- **`immediate`**: trigger the callback immediately on watcher creation. Old value will be `undefined` on the first call.
293293
- **`deep`**: force deep traversal of the source if it is an object or an array, so that the callback fires on deep mutations. See [Deep Watchers](/guide/essentials/watchers.html#deep-watchers).
294-
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing).
294+
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing) and [`watchEffect()`](/api/reactivity-core.html#watcheffect).
295295
- **`onTrack / onTrigger`**: debug the watcher's dependencies. See [Watcher Debugging](/guide/extras/reactivity-in-depth.html#watcher-debugging).
296296
297297
Avoid using arrow functions when declaring watch callbacks as they will not have access to the component instance via `this`.

src/api/reactivity-core.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ Runs a function immediately while reactively tracking its dependencies and re-ru
256256
257257
The second argument is an optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies.
258258
259+
By default, watchers will run just prior to component rendering. Setting `flush: 'post'` will defer the watcher until after component rendering. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing) for more information. In rare cases, it might be necessary to trigger a watcher immediately when a reactive dependency changes, e.g. to invalidate a cache. This can be achieved using `flush: 'sync'`. However, this setting should be used with caution, as it can lead to problems with performance and data consistency if multiple properties are being updated at the same time.
260+
259261
The return value is a handle function that can be called to stop the effect from running again.
260262
261263
- **Example**
@@ -382,7 +384,7 @@ Watches one or more reactive data sources and invokes a callback function when t
382384
383385
- **`immediate`**: trigger the callback immediately on watcher creation. Old value will be `undefined` on the first call.
384386
- **`deep`**: force deep traversal of the source if it is an object, so that the callback fires on deep mutations. See [Deep Watchers](/guide/essentials/watchers.html#deep-watchers).
385-
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing).
387+
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers.html#callback-flush-timing) and [`watchEffect()`](/api/reactivity-core.html#watcheffect).
386388
- **`onTrack / onTrigger`**: debug the watcher's dependencies. See [Watcher Debugging](/guide/extras/reactivity-in-depth.html#watcher-debugging).
387389
388390
Compared to [`watchEffect()`](#watcheffect), `watch()` allows us to:

0 commit comments

Comments
 (0)