/** * Custom hook that debounces a callback function to delay its execution until after * a specified wait time has elapsed since the last time it was invoked. * * Debouncing ensures that the callback is only executed once after a series of rapid calls, * waiting for a pause in the calls before executing. * * @param callback - The function to debounce * @param delay - The delay time (in milliseconds) to wait before executing the callback * @param options - Optional configuration object * @param options.maxWait - Maximum time before function must be invoked * @param options.leading - If true, invoke on the leading edge * @returns A debounced version of the callback function with a `cancel` method * * @example * ```tsx * const debouncedSearch = useDebounce((query: string) => { * console.log('Searching for:', query) * }, 300) * * return debouncedSearch(e.target.value)} /> * ``` * * @example * ```tsx * // With maxWait and leading options * const debouncedSearch = useDebounce( * (query: string) => console.log('Searching for:', query), * 300, * { maxWait: 1000, leading: true } * ) * ``` * * @example * ```tsx * // Cancel pending debounced call * const debouncedSearch = useDebounce((query: string) => { * console.log('Searching for:', query) * }, 300) * * debouncedSearch('test') * debouncedSearch.cancel() // Cancels the pending call * ``` */ export declare const useDebounce: any>(callback: T, delay: number, { maxWait, leading }?: { maxWait?: number; leading?: boolean; }) => T & { cancel: VoidFunction; }; export declare const useDebouncedValue: (value: T, delay?: number) => T;