Debounce Function/Action
Creates a debounced version of a callback that delays its execution until after a specified period of inactivity.
debounceAction
Creates a debounced version of a callback that delays its execution until after a specified period of inactivity. Useful for search, auto-complete, resize, and other rapid trigger scenarios.
Function Signature
function debounceAction<T extends VoidFn>(
callback: T,
delay?: number
): DelayedFn<T>Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
callback | VoidFn | The function to debounce. | — |
delay | number (optional) | Delay in milliseconds. | 300 |
Returns
DelayedFn<T>: A debounced version of the callback function.
Example Usage
playground.ts
Behavior Details
- Delay resetting: Each invocation of the debounced function clears the previous timer and sets a new one. The callback is only executed when the delay period passes without any new calls.
- Arguments Preservation: Arguments passed to the debounced function are forwarded directly to the callback during execution.
Related Functions
- throttleAction — Limits the execution rate of a function.
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
