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:56

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:61

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


initialState?

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

Defined in: batcher.ts:65

Initial state for the batcher


maxSize?

ts
optional maxSize: number;
optional maxSize: number;

Defined in: batcher.ts:70

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:74

Callback fired after a batch is processed

Parameters

batcher

Batcher<TValue>

Returns

void


onItemsChange()?

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

Defined in: batcher.ts:78

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:83

Whether the batcher should start processing immediately

Default

ts
true
true

wait?

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

Defined in: batcher.ts:90

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.