Defined in: async-batcher.ts:86
Options for configuring an AsyncBatcher instance
• TValue
optional getShouldExecute: (items, batcher) => boolean;
optional getShouldExecute: (items, batcher) => boolean;
Defined in: async-batcher.ts:91
Custom function to determine if a batch should be processed Return true to process the batch immediately
TValue[]
AsyncBatcher<TValue>
boolean
optional initialState: Partial<AsyncBatcherState<TValue>>;
optional initialState: Partial<AsyncBatcherState<TValue>>;
Defined in: async-batcher.ts:98
Initial state for the async batcher
optional maxSize: number;
optional maxSize: number;
Defined in: async-batcher.ts:103
Maximum number of items in a batch
Infinity
Infinity
optional onError: (error, failedItems, batcher) => void;
optional onError: (error, failedItems, batcher) => void;
Defined in: async-batcher.ts:109
Optional error handler for when the batch function throws. If provided, the handler will be called with the error and batcher instance. This can be used alongside throwOnError - the handler will be called before any error is thrown.
unknown
TValue[]
AsyncBatcher<TValue>
void
optional onExecute: (batcher) => void;
optional onExecute: (batcher) => void;
Defined in: async-batcher.ts:117
Callback fired after a batch is processed
AsyncBatcher<TValue>
void
optional onItemsChange: (batcher) => void;
optional onItemsChange: (batcher) => void;
Defined in: async-batcher.ts:121
Callback fired after items are added to the batcher
AsyncBatcher<TValue>
void
optional onSettled: (batcher) => void;
optional onSettled: (batcher) => void;
Defined in: async-batcher.ts:125
Optional callback to call when a batch is settled (completed or failed)
AsyncBatcher<TValue>
void
optional onSuccess: (result, batcher) => void;
optional onSuccess: (result, batcher) => void;
Defined in: async-batcher.ts:129
Optional callback to call when a batch succeeds
any
AsyncBatcher<TValue>
void
optional started: boolean;
optional started: boolean;
Defined in: async-batcher.ts:134
Whether the batcher should start processing immediately
true
true
optional throwOnError: boolean;
optional throwOnError: boolean;
Defined in: async-batcher.ts:140
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.
optional wait: number | (asyncBatcher) => number;
optional wait: number | (asyncBatcher) => number;
Defined in: async-batcher.ts:147
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.
Infinity
Infinity
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.