method TaskClass.prototype.then
Private
TaskClass.prototype.then<TResult1 = T, TResult2 = never>(
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
): Promise<TResult1 | TResult2>

Runs the recipe on first await/then. This is the single trigger point for the lazy work — catch and finally route through it too, since both call then per spec.

The signature mirrors Promise.prototype.then exactly (including reason: any, which the lib.d.ts declaration uses) so the subclass stays assignable everywhere a Promise is.

const task = Task(() => [{ name: 'ada' }]);

const names = task.then((users) => users.map((u) => u.name)); // plain Promise out
await names; // ['ada'] — to stay in Task-land (lazy, retryable, typed E), use .map instead

Type Parameters

TResult1 = T
TResult2 = never

Parameters

optional
onfulfilled: ((value: T) => TResult1 | PromiseLike<TResult1>) | null
optional
onrejected: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null

Return Type

Promise<TResult1 | TResult2>

Usage

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