Skip to content

watchWithFilter

类别
导出体积
233 B
上次更改
10 months ago

带有额外 EventFilter 控制的 watch

用法

类似于 watch,但提供了额外选项 eventFilter,该选项将应用于回调函数。

ts
import { 
debounceFilter
,
watchWithFilter
} from '@vueuse/core'
watchWithFilter
(
source, () => {
console
.
log
('changed!') }, // 回调函数将以 500ms 的防抖方式调用
{
eventFilter
:
debounceFilter
(500), // 限流过滤器、可暂停过滤器或自定义过滤器
}, )

类型声明

ts
export interface 
WatchWithFilterOptions
<
Immediate
>
extends WatchOptions<
Immediate
>,
ConfigurableEventFilter {} export declare function
watchWithFilter
<
T
extends
Readonly
<
WatchSource
<unknown>[]>,
Immediate
extends
Readonly
<boolean> = false,
>(
sources
: [...
T
],
cb
:
WatchCallback
<
MapSources
<
T
>,
MapOldSources
<
T
,
Immediate
>>,
options
?:
WatchWithFilterOptions
<
Immediate
>,
):
WatchStopHandle
export declare function
watchWithFilter
<
T
,
Immediate
extends
Readonly
<boolean> = false,
>(
source
:
WatchSource
<
T
>,
cb
:
WatchCallback
<
T
,
Immediate
extends true ?
T
| undefined :
T
>,
options
?:
WatchWithFilterOptions
<
Immediate
>,
):
WatchStopHandle
export declare function
watchWithFilter
<
T
extends object,
Immediate
extends
Readonly
<boolean> = false,
>(
source
:
T
,
cb
:
WatchCallback
<
T
,
Immediate
extends true ?
T
| undefined :
T
>,
options
?:
WatchWithFilterOptions
<
Immediate
>,
):
WatchStopHandle

源码

源码文档

贡献者

Anthony Fu
一纸忘忧
briwa
Anthony Fu
vaakian X
lvjiaxuan

更新日志

0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)