Skip to content

abortable

abortable<A>(factory): object

Defined in: Core/Task.ts:347

Creates a Task paired with an abort handle. When abort() is called the AbortSignal passed to the factory is fired, cancelling any in-flight operation (e.g. a fetch) immediately.

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

A

(signal) => Promise<A>

object

abort: () => void

void

task: Task<A>

const { task: poll, abort } = Task.abortable(
  (signal) => waitForEvent(bus, "ready", { signal }),
);

onUnmount(abort);
await poll();