debouncedWatch.d.ts 1.3 KB

123456789101112131415161718192021222324252627
  1. import type { Ref, WatchOptions, WatchStopHandle } from 'vue';
  2. declare type MaybeRef<T> = T | Ref<T>;
  3. declare type Fn = () => void;
  4. export declare type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return;
  5. export interface FunctionWrapperOptions<Args extends any[] = any[], This = any> {
  6. fn: FunctionArgs<Args, This>;
  7. args: Args;
  8. thisArg: This;
  9. }
  10. export declare type EventFilter<Args extends any[] = any[], This = any> = (invoke: Fn, options: FunctionWrapperOptions<Args, This>) => void;
  11. /**
  12. * Create an EventFilter that debounce the events
  13. *
  14. * @param ms
  15. */
  16. export declare function debounceFilter(ms: MaybeRef<number>): EventFilter<any[], any>;
  17. export interface DebouncedWatchOptions<Immediate> extends WatchOptions<Immediate> {
  18. debounce?: MaybeRef<number>;
  19. }
  20. interface ConfigurableEventFilter {
  21. eventFilter?: EventFilter;
  22. }
  23. export interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {
  24. }
  25. export declare function watchWithFilter<Immediate extends Readonly<boolean> = false>(source: any, cb: any, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
  26. export default function debouncedWatch<Immediate extends Readonly<boolean> = false>(source: any, cb: any, options?: DebouncedWatchOptions<Immediate>): WatchStopHandle;
  27. export {};