Throttle with Debounce
Throttles a function so it can't be called more often than a given delay, while also calling it an additional time if one or more executions were blocked.
Throttles a function so it can't be called more often than a given delay, while also calling it an additional time if one or more executions were blocked.
throttleWithDebounce(fn, delay)
Creates a new version of the function fn
, which will not execute more often than once every delay
milliseconds regardless of how many times it is called. If one or more executions is blocked, it will be called one more time after the delay has passed since the last time it was called.
A function to be throttled.
The number of milliseconds for which the function should be unable to be called after each time it is executed. This delay also serves as the delay before the final execution of the function if it was blocked.
This button has been throttled with a debounce at a delay of 200 ms:
This button has been throttled with a debounce at a delay of 1000 s: