function injectBatchedCallback<TValue>(fn, options): (item) => void;
Defined in: batcher/injectBatchedCallback.ts:40
An Angular function that creates a batched version of a callback function. This function is essentially a wrapper around injectBatcher that provides a simplified API for basic batching needs.
The batched function will collect items and process them in batches based on the configured conditions (maxSize, wait time, etc.).
This function provides a simpler API compared to injectBatcher, making it ideal for basic batching needs. However, it does not expose the underlying Batcher instance.
For advanced usage requiring features like:
Consider using the injectBatcher function instead.
TValue
(items) => void
BatcherOptions<TValue>
(item): void;
TValue
void
// Batch API calls
const batchApiCall = injectBatchedCallback(
(items) => {
return fetch('/api/batch', {
method: 'POST',
body: JSON.stringify(items)
});
},
{ maxSize: 10, wait: 1000 }
);
// Items will be batched and sent together
batchApiCall('item1');
batchApiCall('item2');