vue-hooks-plus
Version:
Vue hooks library
38 lines (37 loc) • 989 B
TypeScript
export interface DebounceOptions {
/**
* The number of milliseconds to delay.
*/
wait?: number;
/**
* Specify invoking on the leading edge of the timeout.
*/
leading?: boolean;
/**
* Specify invoking on the trailing edge of the timeout.
*/
trailing?: boolean;
/**
* The maximum time func is allowed to be delayed before it’s invoked.
*/
maxWait?: number;
}
type noop = (...args: any) => any;
declare function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions): {
/**
* Invode and pass parameters to fn.
* `(...args: any[]) => any`
*/
run: import("lodash-es/debounce").DebouncedFunc<T>;
/**
* Cancel the invocation of currently debounced function.
* `() => void`
*/
cancel: () => void;
/**
* Immediately invoke currently debounced function.
* `() => void`
*/
flush: () => ReturnType<T> | undefined;
};
export default useDebounceFn;