Defined in: batcher.ts:52
Options for configuring a Batcher instance
Type Parameters#
TValue#
TValue
Properties#
getShouldExecute?#
optional getShouldExecute?: (items, batcher) => boolean;
Defined in: batcher.ts:57
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?#
optional initialState?: Partial<BatcherState<TValue>>;
Defined in: batcher.ts:61
Initial state for the batcher
key?#
optional key?: string;
Defined in: batcher.ts:66
Optional key to identify this batcher instance. If provided, the batcher will be identified by this key in the devtools and PacerProvider if applicable.
maxSize?#
optional maxSize?: number;
Defined in: batcher.ts:71
Maximum number of items in a batch
Default#
Infinity
onExecute?#
optional onExecute?: (batch, batcher) => void;
Defined in: batcher.ts:75
Callback fired after a batch is processed
Parameters#
batch#
TValue[]
batcher#
Batcher<TValue>
Returns#
void
onItemsChange?#
optional onItemsChange?: (batcher) => void;
Defined in: batcher.ts:79
Callback fired after items are added to the batcher
Parameters#
batcher#
Batcher<TValue>
Returns#
void
started?#
optional started?: boolean;
Defined in: batcher.ts:84
Whether the batcher should start processing immediately
Default#
true
wait?#
optional wait?: number | ((batcher) => number);
Defined in: batcher.ts:91
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#
Infinity