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

BatcherOptions

Interface: BatcherOptions<TValue>

Defined in: batcher.ts:6

Options for configuring a Batcher instance

Type Parameters

TValue

Properties

getShouldExecute()?

ts
optional getShouldExecute: (items, batcher) => boolean;
optional getShouldExecute: (items, batcher) => boolean;

Defined in: batcher.ts:11

Custom function to determine if a batch should be processed Return true to process the batch immediately

Parameters

items

TValue[]

batcher

Batcher<TValue>

Returns

boolean


maxSize?

ts
optional maxSize: number;
optional maxSize: number;

Defined in: batcher.ts:16

Maximum number of items in a batch

Default

ts
Infinity
Infinity

onExecute()?

ts
optional onExecute: (batcher) => void;
optional onExecute: (batcher) => void;

Defined in: batcher.ts:20

Callback fired after a batch is processed

Parameters

batcher

Batcher<TValue>

Returns

void


onIsRunningChange()?

ts
optional onIsRunningChange: (batcher) => void;
optional onIsRunningChange: (batcher) => void;

Defined in: batcher.ts:24

Callback fired when the batcher's running state changes

Parameters

batcher

Batcher<TValue>

Returns

void


onItemsChange()?

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

Defined in: batcher.ts:28

Callback fired after items are added to the batcher

Parameters

batcher

Batcher<TValue>

Returns

void


started?

ts
optional started: boolean;
optional started: boolean;

Defined in: batcher.ts:33

Whether the batcher should start processing immediately

Default

ts
true
true

wait?

ts
optional wait: number;
optional wait: number;

Defined in: batcher.ts:40

Maximum time in milliseconds to wait before processing a batch. If the wait duration has elapsed, the batch will be processed. If not provided, the batch will not be triggered by a timeout.

Default

ts
Infinity
Infinity
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.