js-util

Home > rc-js-util > fpDebounce

fpDebounce() function

Creates a function that will proxy calls to functionToProxy when wait time has passed since the last call, using the most recent arguments. Where immediate is true, the function immediately proxies the call and will not proxy again until wait time passes since the last call.

Signature:

export declare function fpDebounce<TArgs extends unknown[]>(wait: number, immediate: boolean, functionToProxy: (...args: TArgs) => void): TDebouncedFn<TArgs>;

Parameters

Parameter Type Description
wait number Time to wait in ms.
immediate boolean If true run on the leading edge, default false.
functionToProxy (…args: TArgs) => void The function to debounce.

Returns:

TDebouncedFn<TArgs>

A debounced function.

Remarks

As per underscore’s debounce, except that returns have been disallowed. See fpDebounce().