Обзор
functionCore Runtime

contextWithSignal

Replaces the signal on a runtime context.

Signature

tsSignature
export function contextWithSignal<C extends object>(
context: RuntimeContext<C>,
signal: AbortSignal,
): RuntimeContext<C>;

Imports

tsImport
import { contextWithSignal } from "@/lib/flow/core/runtime";
import { contextWithSignal } from "@/lib/flow";

Type Parameters

C

Custom context type.

Parameters

context

Existing runtime context.

signal
AbortSignal

Replacement signal.

Returns

A context with the same custom fields and the replacement signal.

Return type
RuntimeContext<C>

Details

This advanced helper is used by timeout and parallel helpers when they create child abort

controllers.

when

Branches between two behaviors using a predicate function.

function

Source

tsflow/core/runtime.ts:284-289
export function contextWithSignal<C extends object>(
context: RuntimeContext<C>,
signal: AbortSignal,
): RuntimeContext<C> {
return { ...context, signal };
}