Skip to main content

interface Task.Context

Represents the execution context for Tasks, supporting cancellation, supervision, and child contexts.

Properties

cancel

Cancels this context

Definition

cancel: () => void;

cancelAllChildren

Cancels all child contexts

Definition

cancelAllChildren: () => void;

cancelledSignal

AbortSignal for cancellation

Definition

get cancelledSignal(): AbortSignal;

children

Iterable of child contexts

Definition

get children(): Iterable<Task.Context>;

delay

undocumented

Definition

delay: (delayMs?: number) => Promise<void>;

hasChildren

True if there are child contexts

Definition

get hasChildren(): boolean;

id

Unique context id

Definition

get id(): string;

isActive

True if the context is active (not cancelled)

Definition

get isActive(): boolean;

isCancelled

True if this context is cancelled

Definition

get isCancelled(): boolean;

isSupervisor

True if this context is a supervisor

Definition

get isSupervisor(): boolean;

launch

Launches a task as a background Job in this context. Use for running tasks that can be cancelled or joined later.

Definition

launch: {
      <R = void>(task: Task<R>, options?: (Task.ChildOptions & {
        args?: undefined | [];
      }) |undefined):Task.Job<R>;
      <R = void, A extends readonly any[] = []>(task: Task<R, A>, options: (Task.ChildOptions & {
        args: A;
      }) |undefined):Task.Job<R>;
    };

onCancelled

Registers a callback for cancellation

Definition

onCancelled: (cleanup: Cleanup) => DisposableCallback;

parent

Parent context, if any

Definition

get parent(): Task.Context | undefined;

run

Executes the next task within a running context. Use for chaining tasks or running a task as part of a sequence.

Definition

run: {
      <R = void>(task: Task<R>): Promise<R>;
      <R = void, A extends readonly any[] = []>(task: Task<R, A>, args: A): Promise<R>;
    };

throwIfCancelled

Throws if cancelled

Definition

throwIfCancelled: () => void;