Skip to main content

Function: debounce()

debounce<T>(func, wait, options?): (…args) => void & object
Defined in: throttle.ts:177 Debounce a function to only execute after it stops being called for specified time

Type Parameters

T

T extends AnyFunction

Parameters

func

T Function to debounce

wait

number Wait time in milliseconds

options?

Debounce options

leading?

boolean

maxWait?

number

Returns

(…args) => void & object Debounced function

Example

const search = debounce((query) => fetchSearchResults(query), 300);
search('a'); // Waiting...
search('ab'); // Waiting...
search('abc'); // Executes after 300ms of no calls