@react-cmpt/use-throttle
Version:
The throttled value / function hook for react
20 lines (19 loc) • 607 B
TypeScript
export declare type ThrottleFnOptions = {
/** Specify invoking on the leading edge of the timeout. */
leading?: boolean;
};
export declare type ControlFunctions = {
cancel: () => void;
callPending: () => void;
};
export interface ThrottleReturnResult<T extends any[]> extends ControlFunctions {
callback: (...args: T) => void;
}
/**
* useThrottleFn
*
* @param fn function
* @param wait number @default 0
* @param options object
*/
export default function useThrottleFn<T extends any[]>(fn: (...args: T) => any, wait?: number, options?: ThrottleFnOptions): ThrottleReturnResult<T>;