本页还没有译文
本页 20 段还没译成Français,下面显示的是英文原文。batch
还没翻译译自英文(tanstack.com)本页 20 段都还没译
function batch<TValue>(fn, options): (item) => void;Defined in: batcher.ts:323
Creates a batcher that processes items in batches.
This synchronous version is lighter weight and often all you need - upgrade to asyncBatch when you need promises, retry support, abort/cancel capabilities, or advanced error handling.
Type Parameters
TValue
TValue
Parameters
fn
(items) => void
options
BatcherOptions<TValue>
Returns
(item): void;Adds an item to the batcher If the batch size is reached, timeout occurs, or shouldProcess returns true, the batch will be processed
Parameters
item
TValue
Returns
void
Example
const batchItems = batch<number>(
(items) => console.log('Processing:', items),
{
maxSize: 3,
onExecute: (batch, batcher) => console.log('Batch executed:', batch)
}
);
batchItems(1);
batchItems(2);
batchItems(3); // Triggers batch processingAI 翻译查看英文原文