Function: withConcurrencyLimitAndProgress()
@arolariu/website / lib/utils.client / withConcurrencyLimitAndProgress
Function: withConcurrencyLimitAndProgress()
withConcurrencyLimitAndProgress<
T>(tasks,options?):Promise<(T|Error)[]>
Defined in: lib/concurrency.client.ts:125
Executes async tasks with concurrency limit and progress tracking.
Type Parameters
T
T
Return type of the async tasks
Parameters
tasks
() => Promise<T>[]
Array of async task functions to execute
options?
Configuration options
limit?
number
Maximum number of concurrent tasks (default: 5)
onProgress?
(completed, total) => void
Callback invoked after each task completes
onTaskComplete?
(result, index) => void
Callback invoked for each task result
Returns
Promise<(T | Error)[]>
Promise that resolves to array of task results (in original order)
Remarks
Similar to withConcurrencyLimit but provides progress callbacks for UI updates.
Progress Tracking:
onProgress: Called after each task completesonTaskComplete: Called for each individual task (success or failure)
Example
const uploadTasks = files.map(file => async () => uploadFile(file));
const results = await withConcurrencyLimitAndProgress(uploadTasks, {
limit: 5,
onProgress: (completed, total) => {
console.log(`Progress: ${completed}/${total}`);
},
onTaskComplete: (result, index) => {
console.log(`Task ${index} completed:`, result);
}
});
// was this page useful?