Skip to content

abortable

abortable<E, A>(factory, onError): object

Defined in: Core/TaskResult.ts:288

Creates a TaskResult paired with an abort handle. When abort() is called the AbortSignal passed to the factory is fired, cancelling any in-flight operation. The abort error is transformed by onError into a typed Err.

If an outer signal is also present (passed at the call site), aborting it propagates into the internal controller.

E

A

(signal) => Promise<A>

(e) => E

object

abort: () => void

void

task: TaskResult<E, A>

const { task: req, abort } = TaskResult.abortable(
  (signal) => fetch(`/users/${id}`, { signal }).then(r => r.json()),
  String,
);

const result = pipe(req, TaskResult.retry({ attempts: 3 }));

onCancel(abort);
await result();