Follow one execution
Only the Offline tag selects this fallback; its one cached value follows acquisition.
catchTagTick 0. Input: guide; Output: guide.
Read this diagram
Follow each lane from left to right. Events stacked vertically share a tick; the green cursor marks the current time across every lane.
- A value
The text inside the pill is the emitted value. - Work starts
The raised chevron starts an inner run (^in the source). - The run returns
The vertical bar ends this lane’s run. - A cause is delivered
The exclamation mark belongs to this lane. - Work is interrupted
The cross marks cancellation of this run. - Current time
The line and diamond move together across all lanes. - Happening now
A highlighted event is at the current tick. - Still ahead
Muted, dashed values have not happened yet. - Time continues
The lane’s arrow is not a return marker. An empty stretch can be quiet work that is still running.
Illustrated ticks start at 0. At 1×, one illustrated tick takes one second; captions specify real durations when timing matters. A cause or interruption belongs to its lane, and other work may continue. Scroll horizontally to inspect the rest of a long timeline.
The source owns the subscription until its Cause contains a Fail whose tag matches. That first matching Fail starts one handler Fx and replaces the entire original Cause, including any defects or interrupts composed with it. A Cause with no Fail, or a first Fail with another tag, passes through intact. The fallback is lazy and contributes its errors and services to the result.
Import
import { catchTag } from "@typed/fx/Fx";Signatures
export declare const catchTag: {
<const K extends Tags<E> | Arr.NonEmptyReadonlyArray<Tags<E>>, E, A2, E2, R2>(k: K, f: (e: ExtractTag<NoInfer<E>, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Fx<A2, E2, R2>): <A, R>(self: Fx<A, E, R>) => Fx<A | A2, E2 | ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>, R | R2>;
<A, E, R, const K extends Tags<E> | Arr.NonEmptyReadonlyArray<Tags<E>>, A2, E2, R2>(self: Fx<A, E, R>, k: K, f: (e: ExtractTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Fx<A2, E2, R2>): Fx<A | A2, E2 | ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>, R | R2>;
};Why
Tagged error unions are idiomatic Effect APIs. Selecting one or more tags narrows the handler input and removes only those variants from the returned error channel, preserving the rest for later composition.
Ownership and lifetime
The source owns the subscription until its Cause contains a Fail whose tag matches. That first matching Fail starts one handler Fx and replaces the entire original Cause, including any defects or interrupts composed with it. A Cause with no Fail, or a first Fail with another tag, passes through intact. The fallback is lazy and contributes its errors and services to the result.
Examples
import { catchTag } from "@typed/fx/Fx"
import { fail, succeed } from "@typed/fx/Fx"
type Missing = { readonly _tag: "Missing"; readonly id: string }
const source = fail<Missing>({ _tag: "Missing", id: "42" })
const recovered = catchTag(source, "Missing", ({ id }) => succeed(`missing:${id}`))Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.