vue-hooks-plus
Version:
Vue hooks library
40 lines (39 loc) • 1.1 kB
TypeScript
import { Ref } from 'vue';
export interface DebounceOptions {
/**
* The number of milliseconds to delay.
*/
wait?: number | Ref<number, number>;
/**
* Specify invoking on the leading edge of the timeout.
*/
leading?: boolean | Ref<boolean, boolean>;
/**
* Specify invoking on the trailing edge of the timeout.
*/
trailing?: boolean | Ref<boolean, boolean>;
/**
* The maximum time func is allowed to be delayed before it’s invoked.
*/
maxWait?: number | Ref<number, 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: T;
/**
* Cancel the invocation of currently debounced function.
* `() => void`
*/
cancel: () => void;
/**
* Immediately invoke currently debounced function.
* `() => void`
*/
flush: () => void;
updateOptions: (newOptions: DebounceOptions) => void;
};
export default useDebounceFn;