/** * Hook that debounces a callback function */ import type { AnyCallable, DelayedFunction } from './delayed/types.js'; export type DebounceOptions = { /** * Delay in milliseconds (default: 500) */ delay?: number; /** * Invoke the callback on the leading edge instead of trailing (default: false) */ leading?: boolean; /** * Maximum time the callback can be delayed before being invoked (default: undefined) */ maxWait?: number; }; /** * Debounced function type with cancel, flush, and isPending methods */ export type DebouncedFunction = DelayedFunction; /** * Hook that debounces a callback function with advanced options * * @template T - The callback function type * @param callback - The callback function to debounce * @param options - Debounce configuration options or delay in milliseconds (for backwards compatibility) * @returns The debounced callback function with cancel, flush, and isPending methods * * @example * ```tsx * const SearchForm = () => { * const handleSearch = useDebounceCallback((query: string) => { * console.log('Searching for:', query); * }, { delay: 300, leading: false, maxWait: 1000 }); * * return ( *
* handleSearch(e.target.value)} /> * * *
* ); * }; * ``` * * @remarks * This hook provides a configurable debounce implementation with: * - Leading edge invocation support * - Maximum wait time to ensure periodic execution * - Cancel and flush methods for manual control * - Backwards compatible with simple delay parameter */ export declare function useDebounceCallback(callback: T, options?: DebounceOptions | number): DebouncedFunction; //# sourceMappingURL=useDebounceCallback.d.ts.map