function batch<TValue>(fn, options): (item) => void
function batch<TValue>(fn, options): (item) => void
Defined in: batcher.ts:313
Creates a batcher that processes items in batches
• TValue
(items) => void
BatcherOptions<TValue>
Function
Adds an item to the batcher If the batch size is reached, timeout occurs, or shouldProcess returns true, the batch will be processed
TValue
void
const batchItems = batch<number>(
(items) => console.log('Processing:', items),
{
maxSize: 3,
onExecute: (batcher) => console.log('Batch executed')
}
);
batchItems(1);
batchItems(2);
batchItems(3); // Triggers batch processing
const batchItems = batch<number>(
(items) => console.log('Processing:', items),
{
maxSize: 3,
onExecute: (batcher) => console.log('Batch executed')
}
);
batchItems(1);
batchItems(2);
batchItems(3); // Triggers batch processing
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.