The watcher's source. The source can be one of the following: - A getter function that returns a value - A ref - A reactive object - ...or an array of the above.
The callback that will be called when the source changes. It receives the new and old value(s) as arguments.
Optional
options: WatchOptions<Immediate>Allows to control the watch's behaviour.
Watches one or more reactive data sources and invokes a callback function when the sources change.
const count = ref(0)
watch(count, (count) => {
console.log(count)
return () => console.log('cleanup')
})
count.value++
A function that can be called to stop the watch.
The callback that will be called when the source changes. It receives the new and old value(s) as arguments.
Optional
options: WatchOptions<Immediate>Allows to control the watch's behaviour.
Watches one or more reactive data sources and invokes a callback function when the sources change.
const count = ref(0)
watch(count, (count) => {
console.log(count)
return () => console.log('cleanup')
})
count.value++
A function that can be called to stop the watch.
The callback that will be called when the source changes. It receives the new and old value(s) as arguments.
Optional
options: WatchOptions<Immediate>Allows to control the watch's behaviour.
Watches one or more reactive data sources and invokes a callback function when the sources change.
const count = ref(0)
watch(count, (count) => {
console.log(count)
return () => console.log('cleanup')
})
count.value++
A function that can be called to stop the watch.
The callback that will be called when the source changes. It receives the new and old value(s) as arguments.
Optional
options: WatchOptions<Immediate>Allows to control the watch's behaviour.
Generated using TypeDoc
Watches one or more reactive data sources and invokes a callback function when the sources change.
Example
Returns
A function that can be called to stop the watch.
See
https://vuejs.org/api/reactivity-core.html#watch