Genel bakış
functionCore Record

runChild

Runs a child behavior with a linked abort controller.

Signature

tsSignature
export function runChild<I, O, E, C extends object>(
behavior: Behavior<I, O, E, C>,
input: I,
context: RuntimeContext<C>,
childControllers: AbortController[],
): Promise<Result<O, E | RuntimeError>>;

Imports

tsImport
import { runChild } from "@/lib/flow/core/record";
import { runChild } from "@/lib/flow";

Type Parameters

I

Input type.

O

Output type.

E

Expected domain error type.

C

Custom context type.

Parameters

behavior
Behavior<I, O, E, C>

Child behavior to execute.

input
I

Input passed to the child.

context

Parent runtime context.

childControllers
AbortController[]

Mutable collection of child controllers owned by the parent helper.

Returns

Child result including runtime errors.

Return type
Promise<Result<O, E | RuntimeError>>

Details

This advanced runtime helper lets parent helpers cancel child work independently while still

respecting parent cancellation.

Behavior

Executable Flow workflow unit.

type
input

Creates an identity behavior for starting typed pipelines.

function
Result

Explicit success-or-failure outcome used throughout Flow.

type
RuntimeError

Runtime-level failure union added around every behavior's domain error type.

type

Source

tsflow/core/record.ts:152-164
export function runChild<I, O, E, C extends object>(
behavior: Behavior<I, O, E, C>,
input: I,
context: RuntimeContext<C>,
childControllers: AbortController[],
): Promise<Result<O, E | RuntimeError>> {
const { controller, unlink } = createLinkedController(context.signal);
childControllers.push(controller);
return runBehavior(behavior, input, contextWithSignal(context, controller.signal)).finally(
unlink,
);
}