a function that returns the values to watch.
a function that will be executed whenever the watched values changed.
Optional
options: WatchOptions<Values> & { immediate?: false }additional options.
This overload is used when immediate
is not set to false
.
a function that returns the values to watch.
a function that will be executed whenever the watched values changed.
Optional
options: WatchOptions<Values>additional options.
Watches reactive values and executes a callback whenever those values change.
This function is the synchronous variant of watch. It will re-execute after every fine grained change, even if those changes occur in immediate succession.
syncWatch
should therefore be considered a low level primitive, for most use cases watch should be the right tool instead.Example:
syncWatch
returns a handle that can be used to unsubscribe from changes. That handle'sdestroy()
function should be called to stop watching when you are no longer interested in updates: