Genel bakış
functionParallel Execution

all

Runs keyed behaviors in parallel and fails fast on the first child failure.

Signature

tsSignature
export function all<const B extends BehaviorRecord>(
behaviors: B,
options?: { concurrency?: number },
): Behavior<RecordInput<B>, OutputRecord<B>, ErrorUnion<B>, RecordContext<B>>;

Imports

tsImport
import { all } from "@/lib/flow/all";
import { all } from "@/lib/flow";

Type Parameters

B

Behavior record type.

Parameters

behaviors
B

Keyed behaviors to run with the same input.

options
{ concurrency?: number }

Optional concurrency limit.

Returns

A behavior producing a keyed output record or the first child error.

Details

Successful output preserves the input object keys. When a child fails, active siblings are

aborted and the first domain or runtime error is returned.

Examples

tsExample
const loadPage = all({
profile: loadProfile,
settings: loadSettings,
});
Behavior

Executable Flow workflow unit.

type
ErrorUnion

Unions the expected domain error types of every behavior in a record.

type
input

Creates an identity behavior for starting typed pipelines.

function
OutputRecord

Maps each behavior key to its successful output type.

type
RecordContext

Intersects the custom context types of every behavior in a record.

type

Source

tsflow/all.ts:40-51
export function all<const B extends BehaviorRecord>(
behaviors: B,
options?: { concurrency?: number },
): Behavior<RecordInput<B>, OutputRecord<B>, ErrorUnion<B>, RecordContext<B>> {
return async (input, context) => {
if (context.signal.aborted) {
return resultFromSignal(context.signal);
}
return runAll(behaviors, input, context, options?.concurrency);
};
}