Signature
tsSignature
export function tap<I, O, E, C extends object>( source: Behavior<I, O, E, C>, effect: (output: O, context: RuntimeContext<C>) => Awaitable<void>,): Behavior<I, O, E, C>;Imports
tsImport
import { tap } from "@/lib/flow/tap";import { tap } from "@/lib/flow";Type Parameters
Parameters
effect(output: O, context: RuntimeContext<C>) => Awaitable<void>
Side-effect callback invoked only after source success.
Returns
A behavior with the same input, output, and domain error types.
Return type
Behavior<I, O, E, C>Details
Source failures pass through unchanged. Thrown effect errors are captured by the underlying task
runtime as `Thrown`.
Examples
tsExample
const auditedLoad = tap(loadUser, (user) => audit("loaded", user.id));Related Symbols
Awaitable
Represents a value that may be returned directly or through a Promise.
type
Behavior
Executable Flow workflow unit.
type
RuntimeContext
Execution context passed to every behavior.
type
Source
tsflow/tap.ts:25-36
export function tap<I, O, E, C extends object>( source: Behavior<I, O, E, C>, effect: (output: O, context: RuntimeContext<C>) => Awaitable<void>,): Behavior<I, O, E, C> { return pipe( source, task<O, O, never, C>(async (output, context) => { await effect(output, context); return context.ok(output); }), );}