debounce
function debounce<T, R>(fn, waitDuration): {
(this, ...args): Promise<R>;
cancel: () => void;
};
An higher-order-function that debounce a given function to only invoke after N amount of time passes since its last call.
Note: Can be extended in the future to allow immediate (leading) flag and cancel method options.
Type Parameters
| Type Parameter |
|---|
T extends unknown[] |
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | Fn<T, R> | The function to throttle. |
waitDuration | number | The number of milliseconds to wait before invoke. |
Returns
(this, ...args): Promise<R>;
Parameters
| Parameter | Type |
|---|---|
this | unknown |
...args | T |
Returns
Promise<R>
| Name | Type |
|---|---|
cancel() | () => void |