Skip to main content

Interface: UseRateLimitedCallbackOptions<A>

Defined in: use-rate-limited-callback.ts:11

Options for useRateLimitedCallback.

Type Parameters​

A​

A extends unknown[] = unknown[]

Properties​

limit​

limit: number

Defined in: use-rate-limited-callback.ts:18

The most calls that may run within windowMs, and the size of a burst. It is rounded down; a value below 1 means no call ever runs.


maxQueue?​

optional maxQueue?: number

Defined in: use-rate-limited-callback.ts:35

The most calls kept waiting when overflow is "queue". A call that finds the queue full is dropped. Default is Infinity.


onLimited?​

optional onLimited?: (...args) => void

Defined in: use-rate-limited-callback.ts:41

Called synchronously with the arguments of every call that is dropped: none left in "drop" mode, or a full queue in "queue" mode. Not called when a queued call is discarded by cancel or on unmount.

Parameters​

args​

...A

Returns​

void


overflow?​

optional overflow?: "drop" | "queue"

Defined in: use-rate-limited-callback.ts:30

What to do with a call that arrives when no token is left: "drop" discards it, "queue" runs it, in order, as tokens refill. Default is "drop".


windowMs​

windowMs: number

Defined in: use-rate-limited-callback.ts:24

The window, in milliseconds, over which limit calls are allowed. Tokens refill smoothly at limit / windowMs per millisecond. 0 or less means no limit.