BACK
Use casesParallel uploads — parallel loading with a limit
Use cases · 04

Parallel uploads — parallel loading with a limit

Pattern

When the user drops 20 files, we don't want to open 20 simultaneous connections. We want: at most 3 in flight, the rest waiting in a queue, and progress updating as each one finishes.

The operators and their roles

  • from(files) — turn the array into a stream.
  • mergeMap(uploader, concurrent) — parallelism with a limit.
  • scan — accumulate a counter of the completed ones.

What we achieve

Control over the number of concurrent requests and an automatic progress bar.

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...