Genel bakış
functionParallel Execution

allSettled

Runs keyed behaviors and collects every child result.

Signature

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

Imports

tsImport
import { allSettled } from "@/lib/flow/all-settled";
import { allSettled } 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 record of child results.

Return type
Behavior<RecordInput<B>, SettledRecord<B>, never, RecordContext<B>>

Details

Unlike `all`, domain failures from one child do not cancel siblings. Parent cancellation still

aborts active children and returns a cancellation runtime error for the whole operation.

Examples

tsExample
const loadEverything = allSettled({
profile: loadProfile,
recommendations: loadRecommendations,
});
all

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

function
Behavior

Executable Flow workflow unit.

type
from

Converts a structural result-like value into a branded Flow result.

function
RecordContext

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

type
SettledRecord

Maps each behavior key to the full result returned by that child.

type

Source

tsflow/all-settled.ts:39-50
export function allSettled<const B extends BehaviorRecord>(
behaviors: B,
options?: { concurrency?: number },
): Behavior<RecordInput<B>, SettledRecord<B>, never, RecordContext<B>> {
return async (input, context) => {
if (context.signal.aborted) {
return resultFromSignal(context.signal);
}
return runSettled(behaviors, input, context, options?.concurrency);
};
}