Replies: 2 comments 1 reply
-
If you use the const asyncBatcher = useAsyncBatcher(processBatch, {
maxSize: 5, // Process in batches of 5 (if reached before wait time)
wait: 4000, // Wait up to 4 seconds before processing a batch
onError: (error: unknown, batcher) => {
console.error('Batch failed:', error)
batcher.stop() // stop auto-executing by wait time
setErrorState() // set your custom error state to disable
},
}) But honestly, more around a disabled state could be done here. This batcher util is a little different from the others, as it can execute when batch size or wait time conditions are achieved. The current logic only disables the wait tiime portion. |
Beta Was this translation helpful? Give feedback.
-
Await the Promise: Yes, you should await the promise in the batcher to ensure each batch completes before the next starts.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I want to send requests to remote endpoints in batches because the remote server is not able to cope up the huge number of requests). So I want to send 3 requests, and then another 3 requests and then ...
So the following is how the
batcher
look like,Questions
batcher
?batcher
? I want it to stop process the next batches when error is thrown.Beta Was this translation helpful? Give feedback.
All reactions