Previous: Route Tasks
ember-concurrency provides Task-aware variants of Promise.all and Promise.race, which can be used in cases where a parent task wants to wait for multiple child tasks to run to completion (or throw an error) before continuing onward. The ember-concurrency variants both have the added benefit that if the parent task is canceled (or restarts), all of the child tasks will be automatically canceled. Similarly, in the case of all(), if any of the child tasks throws an error, all other child tasks are immediately canceled.
The example below can be started (or restarted) using either
all()
to wait for all child tasks to run to completion,
or race()
to wait for the first. Note that how, in both cases,
maxConcurrency: 3
ensures that only 3 progress tasks
run at a time, but if you restart the task while it's running, it immediately
starts 3 tasks after canceling the previous ones.
Previous: Route Tasks