Skip to content

race

race<A>(tasks): Task<A>

Defined in: Core/Task.ts:261

Resolves with the value of the first Task to complete. All Tasks start immediately; the rest are abandoned once one resolves.

A

readonly Task<A>[]

Task<A>

const fast = Task.from(() => new Promise<string>(r => setTimeout(() => r("fast"), 10)));
const slow = Task.from(() => new Promise<string>(r => setTimeout(() => r("slow"), 200)));

await Task.race([fast, slow])(); // "fast"