Framework
Version
Debouncer API Reference
Throttler API Reference
Rate Limiter API Reference
Queue API Reference

AsyncDebouncerOptions

Interface: AsyncDebouncerOptions<TFn>

Defined in: async-debouncer.ts:7

Options for configuring an async debounced function

Type Parameters

TFn extends AnyAsyncFunction

Properties

enabled?

ts
optional enabled: boolean | (debouncer) => boolean;
optional enabled: boolean | (debouncer) => boolean;

Defined in: async-debouncer.ts:13

Whether the debouncer is enabled. When disabled, maybeExecute will not trigger any executions. Can be a boolean or a function that returns a boolean. Defaults to true.


leading?

ts
optional leading: boolean;
optional leading: boolean;

Defined in: async-debouncer.ts:18

Whether to execute on the leading edge of the timeout. Defaults to false.


onError()?

ts
optional onError: (error, debouncer) => void;
optional onError: (error, debouncer) => void;

Defined in: async-debouncer.ts:24

Optional error handler for when the debounced function throws. If provided, the handler will be called with the error and debouncer instance. This can be used alongside throwOnError - the handler will be called before any error is thrown.

Parameters

error

unknown

debouncer

AsyncDebouncer<TFn>

Returns

void


onSettled()?

ts
optional onSettled: (debouncer) => void;
optional onSettled: (debouncer) => void;

Defined in: async-debouncer.ts:28

Optional callback to call when the debounced function is executed

Parameters

debouncer

AsyncDebouncer<TFn>

Returns

void


onSuccess()?

ts
optional onSuccess: (result, debouncer) => void;
optional onSuccess: (result, debouncer) => void;

Defined in: async-debouncer.ts:32

Optional callback to call when the debounced function is executed

Parameters

result

ReturnType<TFn>

debouncer

AsyncDebouncer<TFn>

Returns

void


throwOnError?

ts
optional throwOnError: boolean;
optional throwOnError: boolean;

Defined in: async-debouncer.ts:38

Whether to throw errors when they occur. Defaults to true if no onError handler is provided, false if an onError handler is provided. Can be explicitly set to override these defaults.


trailing?

ts
optional trailing: boolean;
optional trailing: boolean;

Defined in: async-debouncer.ts:43

Whether to execute on the trailing edge of the timeout. Defaults to true.


wait

ts
wait: number | (debouncer) => number;
wait: number | (debouncer) => number;

Defined in: async-debouncer.ts:49

Delay in milliseconds to wait after the last call before executing. Can be a number or a function that returns a number. Defaults to 0ms

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.