/** * Hook that throttles a callback function */ import type { AnyCallable, DelayedFunction } from './delayed/types.js'; export type ThrottleOptions = { /** * Delay in milliseconds (default: 500) */ delay?: number; /** * Invoke the callback on the leading edge (default: true) */ leading?: boolean; /** * Invoke the callback on the trailing edge (default: true) */ trailing?: boolean; }; /** * Throttled function type with cancel, flush, and isPending methods */ export type ThrottledFunction = DelayedFunction; /** * Hook that throttles a callback function with advanced options * * @template T - The callback function type * @param callback - The callback function to throttle * @param options - Throttle configuration options or delay in milliseconds (for backwards compatibility) * @returns The throttled callback function with cancel, flush, and isPending methods * * @example * ```tsx * const Component = () => { * const handleScroll = useThrottleCallback(() => { * console.log('Scrolled'); * }, { delay: 100, leading: true, trailing: true }); * * return ( *
* Content * * *
* ); * }; * ``` * * @remarks * This hook provides a configurable throttle implementation with: * - Leading and trailing edge invocation control * - Cancel and flush methods for manual control * - Backwards compatible with simple delay parameter */ export declare function useThrottleCallback(callback: T, options?: ThrottleOptions | number): ThrottledFunction; //# sourceMappingURL=useThrottleCallback.d.ts.map