@rbxts/pretty-react-hooks
Version:
Useful hooks for @rbxts/react
23 lines (22 loc) • 1.01 kB
TypeScript
import { ThrottleOptions } from "@rbxts/set-timeout";
import { UseDebounceResult } from "../use-debounce-callback";
export interface UseThrottleOptions extends ThrottleOptions {
/**
* The amount of time to wait before the first call.
*/
wait?: number;
}
/**
* Creates a throttled function that only invokes `callback` at most once per
* every `wait` seconds. The `callback` is invoked with the most recent arguments
* provided to the throttled function. Subsequent calls to the throttled function
* return the result of the last `callback` invocation.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `throttle` and `debounce`.
*
* @param callback The function to throttle.
* @param options The options object.
* @returns The new throttled function.
*/
export declare function useThrottleCallback<T extends Callback>(callback: T, options?: UseThrottleOptions): UseDebounceResult<T>;