An enhanced version of effect from @vue/reactivity, adding support for a cleanup function.
effect
@vue/reactivity
Registers the given function to track reactive updates.
The given function will be run once immediately. Every time any reactive property that's accessed within it gets updated, the function will run again.
const count = ref(0)effect(() => { console.log(count.value) return () => console.log('cleanup')})count.value++
A runner that can be used to control the effect after creation.
The function that will track reactive updates. The return value from this function will be used as a cleanup function.
Optional
Allows to control the effect's behaviour.
Generated using TypeDoc
An enhanced version of
effect
from@vue/reactivity
, adding support for a cleanup function.Registers the given function to track reactive updates.
The given function will be run once immediately. Every time any reactive property that's accessed within it gets updated, the function will run again.
Example
Returns
A runner that can be used to control the effect after creation.