Framework
Version
防抖器 API 參考
節流器 API 參考
速率限制器 API 參考
佇列 API 參考

AsyncThrottlerOptions

Interface: AsyncThrottlerOptions<TFn>

Defined in: async-throttler.ts:6

Options for configuring an async throttled function

Type Parameters

TFn extends AnyAsyncFunction

Properties

enabled?

ts
optional enabled: boolean;
optional enabled: boolean;

Defined in: async-throttler.ts:11

Whether the throttler is enabled. When disabled, maybeExecute will not trigger any executions. Defaults to true.


leading?

ts
optional leading: boolean;
optional leading: boolean;

Defined in: async-throttler.ts:16

Whether to execute the function immediately when called Defaults to true


onError()?

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

Defined in: async-throttler.ts:20

Optional error handler for when the throttled function throws

Parameters

error

unknown

asyncThrottler

AsyncThrottler<TFn>

Returns

void


onSettled()?

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

Defined in: async-throttler.ts:24

Optional function to call when the throttled function is executed

Parameters

asyncThrottler

AsyncThrottler<TFn>

Returns

void


onSuccess()?

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

Defined in: async-throttler.ts:28

Optional function to call when the throttled function is executed

Parameters

result

ReturnType<TFn>

asyncThrottler

AsyncThrottler<TFn>

Returns

void


trailing?

ts
optional trailing: boolean;
optional trailing: boolean;

Defined in: async-throttler.ts:36

Whether to execute the function on the trailing edge of the wait period Defaults to true


wait

ts
wait: number;
wait: number;

Defined in: async-throttler.ts:41

Time window in milliseconds during which the function can only be executed once 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.