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

AsyncQueuerOptions

Interface: AsyncQueuerOptions<TValue>

Defined in: async-queuer.ts:100

Type Parameters

TValue

Properties

addItemsTo?

ts
optional addItemsTo: QueuePosition;
optional addItemsTo: QueuePosition;

Defined in: async-queuer.ts:105

Default position to add items to the queuer

Default

ts
'back'
'back'

concurrency?

ts
optional concurrency: number | (queuer) => number;
optional concurrency: number | (queuer) => number;

Defined in: async-queuer.ts:111

Maximum number of concurrent tasks to process. Can be a number or a function that returns a number.

Default

ts
1
1

expirationDuration?

ts
optional expirationDuration: number;
optional expirationDuration: number;

Defined in: async-queuer.ts:116

Maximum time in milliseconds that an item can stay in the queue If not provided, items will never expire


getIsExpired()?

ts
optional getIsExpired: (item, addedAt) => boolean;
optional getIsExpired: (item, addedAt) => boolean;

Defined in: async-queuer.ts:121

Function to determine if an item has expired If provided, this overrides the expirationDuration behavior

Parameters

item

TValue

addedAt

number

Returns

boolean


getItemsFrom?

ts
optional getItemsFrom: QueuePosition;
optional getItemsFrom: QueuePosition;

Defined in: async-queuer.ts:126

Default position to get items from during processing

Default

ts
'front'
'front'

getPriority()?

ts
optional getPriority: (item) => number;
optional getPriority: (item) => number;

Defined in: async-queuer.ts:132

Function to determine priority of items in the queuer Higher priority items will be processed first If not provided, will use static priority values attached to tasks

Parameters

item

TValue

Returns

number


initialItems?

ts
optional initialItems: TValue[];
optional initialItems: TValue[];

Defined in: async-queuer.ts:136

Initial items to populate the queuer with


initialState?

ts
optional initialState: Partial<AsyncQueuerState<TValue>>;
optional initialState: Partial<AsyncQueuerState<TValue>>;

Defined in: async-queuer.ts:140

Initial state for the async queuer


key?

ts
optional key: string;
optional key: string;

Defined in: async-queuer.ts:145

Optional key to identify this async queuer instance. If provided, the async queuer will be identified by this key in the devtools and PacerProvider if applicable.


maxSize?

ts
optional maxSize: number;
optional maxSize: number;

Defined in: async-queuer.ts:149

Maximum number of items allowed in the queuer


onError()?

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

Defined in: async-queuer.ts:155

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

Parameters

error

unknown

item

TValue

queuer

AsyncQueuer<TValue>

Returns

void


onExpire()?

ts
optional onExpire: (item, queuer) => void;
optional onExpire: (item, queuer) => void;

Defined in: async-queuer.ts:159

Callback fired whenever an item expires in the queuer

Parameters

item

TValue

queuer

AsyncQueuer<TValue>

Returns

void


onItemsChange()?

ts
optional onItemsChange: (queuer) => void;
optional onItemsChange: (queuer) => void;

Defined in: async-queuer.ts:163

Callback fired whenever an item is added or removed from the queuer

Parameters

queuer

AsyncQueuer<TValue>

Returns

void


onReject()?

ts
optional onReject: (item, queuer) => void;
optional onReject: (item, queuer) => void;

Defined in: async-queuer.ts:167

Callback fired whenever an item is rejected from being added to the queuer

Parameters

item

TValue

queuer

AsyncQueuer<TValue>

Returns

void


onSettled()?

ts
optional onSettled: (item, queuer) => void;
optional onSettled: (item, queuer) => void;

Defined in: async-queuer.ts:171

Optional callback to call when a task is settled

Parameters

item

TValue

queuer

AsyncQueuer<TValue>

Returns

void


onSuccess()?

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

Defined in: async-queuer.ts:175

Optional callback to call when a task succeeds

Parameters

result

any

item

TValue

queuer

AsyncQueuer<TValue>

Returns

void


started?

ts
optional started: boolean;
optional started: boolean;

Defined in: async-queuer.ts:179

Whether the queuer should start processing tasks immediately or not.


throwOnError?

ts
optional throwOnError: boolean;
optional throwOnError: boolean;

Defined in: async-queuer.ts:185

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.


wait?

ts
optional wait: number | (queuer) => number;
optional wait: number | (queuer) => number;

Defined in: async-queuer.ts:191

Time in milliseconds to wait between processing items. Can be a number or a function that returns a number.

Default

ts
0
0
Our Partners
Code Rabbit
Unkey
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.

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.