API reference@evolu/commonTask › concurrently

Call Signature

function concurrently<T, E, D>(
  concurrency: Concurrency,
  task: Task<T, E, D>,
): Task<T, E, D>;

Defined in: packages/common/src/Task.ts:1609

Runs tasks concurrently instead of sequentially.

Sets the Concurrency level for a Task, which helpers like all, map, etc. use to control how many tasks run at once.

By default, tasks run sequentially (one at a time) to encourage thinking about concurrency explicitly.

For tuple-based calls like all([taskA, taskB, taskC]) with a known small number of tasks, omit the limit (runs unlimited). For arrays of unknown length, always specify a limit.

Concurrency is inherited by child tasks and can be overridden at any level. Composition helpers should respect inherited concurrency — they should not override it with a fixed number unless semantically required (like race). Helpers with a recommended concurrency should export it for use with concurrently.

Example

// Unlimited (omit the limit)
run(concurrently(all([fetchA, fetchB, fetchC])));

// Limited — at most 5 tasks run at a time
run(concurrently(5, all(tasks)));
run(concurrently(5, map(userIds, fetchUser)));

// Inherited — inner all() uses parent's limit
const pipeline = concurrently(5, async (run) => {
  const users = await run(map(userIds, fetchUser)); // uses 5
  if (!users.ok) return users;
  return run(map(users.value, enrichUser)); // also uses 5
});

Call Signature

function concurrently<T, E, D>(task: Task<T, E, D>): Task<T, E, D>;

Defined in: packages/common/src/Task.ts:1614

Unlimited.