Skip to content

debounceLatestWithPool()

Function

debounceLatestWithPool<Args, Return>(pool: ConcurrencyPool, fn: Function): Function

Debounce the given function. Only one instance of the function can ever run. The pool is required on purpose, because the only reason you would want to use this instead of a normal debounce function is to also acquire a concurrency token when it runs.

The returned function returns the result of the last call to all previous invocations on purpose and might be called multiple times itself. If you only want the function to execute one on multiple invocations then take a look at reusePending.

Source: packages/concurrency-utils/src/lib/debounce-latest.ts:20

Type parameters

Parameter
Args extends unknown[]
Return

Parameters

ParameterType
poolConcurrencyPool
fn(...params: Args) => Promise<Return>

Returns

Function

(...args: Args): Promise<Return>

Parameters

ParameterType
...argsArgs

Returns

Promise<Return>