The list of tasks to wait on.
Given an array of tasks, return a new Task
which resolves once all tasks
successfully resolve or any task rejects.
Once all tasks resolve:
import { all, timer } from 'true-myth/task';
let allTasks = all([
timer(10),
timer(100),
timer(1_000),
]);
let result = await allTasks;
console.log(result.toString()); // [Ok(10,100,1000)]
If any tasks do not resolve:
let { task: willReject, reject } = Task.withResolvers<never, string>();
let allTasks = all([
timer(10),
timer(20),
willReject,
]);
reject("something went wrong");
let result = await allTasks;
console.log(result.toString()); // Err("something went wrong")
The list of tasks to wait on.
Given an array of tasks, return a new
Task
which resolves once all tasks successfully resolve or any task rejects.Examples
Once all tasks resolve:
If any tasks do not resolve: