rooks
Version:
Essential React custom hooks ⚓ to super charge your components!
26 lines • 996 B
TypeScript
import { AnyFunction } from "@/types/utils";
interface DebounceSettings {
leading?: boolean;
maxWait?: number;
trailing?: boolean;
}
type DebouncedFunction<T extends (...args: any[]) => any> = T & {
cancel(): void;
flush(): ReturnType<T> | undefined;
};
/**
* Debounce hook
* Debounces a function
*
* @param callback The callback to debounce
* @param wait The duration to debounce
* @param options The options object.
* @param options.leading Specify invoking on the leading edge of the timeout.
* @param options.maxWait The maximum time func is allowed to be delayed before it's invoked.
* @param options.trailing Specify invoking on the trailing edge of the timeout.
* @returns Returns the new debounced function.
* @see https://rooks.vercel.app/docs/useDebounce
*/
declare function useDebounce<T extends AnyFunction>(callback: T, wait?: number, options?: DebounceSettings): DebouncedFunction<T>;
export { useDebounce };
//# sourceMappingURL=useDebounce.d.ts.map