API reference › @evolu/common › Task › all
Call Signature
function all<T>(
tasks: T,
options?: CollectOptions<true>,
): Task<
{ [K in string | number | symbol]: InferTaskOk<T[K]> },
InferTaskErr<T[number]>,
InferTaskDeps<T[number]>
>;
Defined in: packages/common/src/Task.ts:3022
Fails fast on first error across multiple Tasks.
Sequential by default — use concurrently to run concurrently.
Example
const result = await run(all([fetchUser, fetchPosts, fetchComments]));
if (!result.ok) return result;
const [user, posts, comments] = result.value;
See
Call Signature
function all<T>(
tasks: T,
options?: CollectOptions<true>,
): Task<
{ [P in string | number | symbol]: InferTaskOk<T[P]> },
[keyof T] extends [never] ? never : InferTaskErr<T[keyof T]>,
[keyof T] extends [never] ? unknown : InferTaskDeps<T[keyof T]>
>;
Defined in: packages/common/src/Task.ts:3042
Returns object with same keys.
const result = await run(all({ user: fetchUser, posts: fetchPosts }));
if (!result.ok) return result;
const { user, posts } = result.value;
Call Signature
function all<T, E, D>(
tasks: Iterable<Task<T, E, D>>,
options?: CollectOptions<true>,
): Task<readonly T[], E, D>;
Defined in: packages/common/src/Task.ts:3061
For dynamic or generated task lists.
const urls: ReadonlyArray<string> = getUrls();
const result = await run(map(urls, fetchUrl));
if (!result.ok) return result;
// result.value: ReadonlyArray<Response>
Call Signature
function all<T, E, D>(
tasks: readonly [Task<T, E, D>, Task<T, E, D>],
options?: CollectOptions<true>,
): Task<readonly [T, T], E, D>;
Defined in: packages/common/src/Task.ts:3079
Guarantees non-empty result.
const tasks: NonEmptyReadonlyArray<Task<Response, FetchError>> = [
fetchUrl("/a"),
fetchUrl("/b"),
];
const result = await run(all(tasks));
if (!result.ok) return result;
// result.value: NonEmptyReadonlyArray<Response>
Call Signature
function all<T, E, D>(
tasks:
| Iterable<Task<T, E, D>, any, any>
| Readonly<Record<string, Task<T, E, D>>>,
options: CollectOptions<false>,
): Task<void, E, D>;
Defined in: packages/common/src/Task.ts:3092
Run for side effects only.
const result = await run(all(tasks, { collect: false }));
// result.value: void