method TaskClass.async
Private
TaskClass.async<T, E = AnyFailure>(source: Recipe<T> | Executor<T>): TaskClass<T, E>

Elixir's Task.async/1: build the task AND start it now — the async half of the async/await pair, for running work concurrently with the code that follows.

const a = Task.async(() => 2);
const b = Task.async(() => 3); // both running before either is awaited
(await a.await()) + (await b.await()); // 5

Type Parameters

E = AnyFailure

Parameters

source: Recipe<T> | Executor<T>

Return Type

Usage

import { TaskClass } from "lib/task/task.ts";