コンテンツへスキップ

watchWithFilter

カテゴリ
エクスポートサイズ
373 B
最終更新日
先週

追加のEventFilter制御を備えたwatch

使い方

watch と同様ですが、コールバック関数に適用される追加オプション eventFilter を提供します。

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
  },
)

型宣言

typescript
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

変更履歴

v12.0.0-beta.1 2024/11/21
0a9ed - feat!: Vue 2のサポートを削除、バンドルを最適化し、クリーンアップしました (#4349)

MITライセンスに基づいてリリースされています。