主题
watchWithFilter
watch 带有额外的 EventFilter 控制。
用法
🌐 Usage
类似于 watch,但提供了一个额外选项 eventFilter,该选项将应用于回调函数。
🌐 Similar to watch, but offering an extra option eventFilter which will be applied to the callback function.
ts
import { debounceFilter, watchWithFilter } from '@vueuse/core'
watchWithFilter(
source,
() => { console.log('changed!') }, // callback will be called in 500ms debounced manner
{
eventFilter: debounceFilter(500), // throttledFilter, pausableFilter or custom filters
},
)