function batch<TValue>(fn, options): (item) => void
function batch<TValue>(fn, options): (item) => void
定义于: batcher.ts:305
创建一个处理批处理项目的批处理器
• TValue
(items) => void
BatcherOptions<TValue>
Function
向批处理器添加一个项目。如果达到批处理大小、发生超时或 shouldProcess 返回 true,则将处理该批处理。
TValue
void
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 processing
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 processing
您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。