Skip to content

Commit

Permalink
watch() once option
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 29, 2023
1 parent 5e486e4 commit 4b4e0b9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/reactivity-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ Watches one or more reactive data sources and invokes a callback function when t
flush?: 'pre' | 'post' | 'sync' // default: 'pre'
onTrack?: (event: DebuggerEvent) => void
onTrigger?: (event: DebuggerEvent) => void
once?: boolean // default: false (3.4+)
}
```
Expand All @@ -387,6 +388,7 @@ Watches one or more reactive data sources and invokes a callback function when t
- **`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#deep-watchers).
- **`flush`**: adjust the callback's flush timing. See [Callback Flush Timing](/guide/essentials/watchers#callback-flush-timing) and [`watchEffect()`](/api/reactivity-core#watcheffect).
- **`onTrack / onTrigger`**: debug the watcher's dependencies. See [Watcher Debugging](/guide/extras/reactivity-in-depth#watcher-debugging).
- **`once`**: run the callback only once. The watcher is automatically stopped after the first callback run. <sup class="vt-badge" data-text="3.4+" />
Compared to [`watchEffect()`](#watcheffect), `watch()` allows us to:
Expand Down

0 comments on commit 4b4e0b9

Please sign in to comment.