Signature
tsSignature
export function delay<I, O, E, C extends object>( source: Behavior<I, O, E, C>, ms: number,): Behavior<I, O, E | TimingError, C>;Imports
tsImport
import { delay } from "@/lib/flow/delay";import { delay } from "@/lib/flow";Type Parameters
IInput type.
OSource output type.
ESource domain error type.
CCustom context type.
Parameters
msnumber
Delay in milliseconds before source execution.
Returns
A behavior with the source result or timing errors.
Return type
Behavior<I, O, E | TimingError, C>Details
`delay` models a pause that is part of the workflow itself. Cancellation during the delay returns
a timing cancellation error and the source behavior is not started.
Examples
tsExample
const delayedLoad = delay(loadUser, 250);Related Symbols
Behavior
Executable Flow workflow unit.
type
type
Source
tsflow/delay.ts:24-41
export function delay<I, O, E, C extends object>( source: Behavior<I, O, E, C>, ms: number,): Behavior<I, O, E | TimingError, C> { return async (input: I, context: RuntimeContext<C>) => { if (context.signal.aborted) { return resultFromSignal(context.signal); }
const delayResult = await wait(ms, context.signal);
if (!delayResult.ok) { return delayResult; }
return runBehavior(source, input, context); };}