Follow one execution
Maps each element to an inner Fx and concatenates the results sequentially. This scenario uses concurrent source deliveries: a pending source callback can wait for admission while another callback is already active.
concatMapTick 0. Input: a; A: start.
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.
Source and inner failures are forwarded to the output Sink, and both service requirements remain in the returned type. The required Scope owns the admitted inner fiber; interruption closes it and prevents queued source work from starting. No values are dropped, switched, or replayed.
Import
import { concatMap } from "@typed/fx/Fx";Signatures
export declare const concatMap: FlatMapLike;Why
concatMap is the flattening policy for work that must not overlap: the next
source value is admitted only after the current inner Fx completes. It is the
bounded-concurrency form of {@link flatMapConcurrently } with a limit of one.
Ordering and cardinality
Every source value creates exactly one inner Fx. Inner values retain both source order and their order within each inner Fx; no inner value is buffered behind a later inner because later inners have not started yet.
Ownership and lifetime
Source and inner failures are forwarded to the output Sink, and both service
requirements remain in the returned type. The required Scope owns the
admitted inner fiber; interruption closes it and prevents queued source work
from starting. No values are dropped, switched, or replayed.
Examples
import { Fx } from "@typed/fx"
import { Effect } from "effect"
const ordered = Fx.concatMap(Fx.fromIterable([
{ id: "first", wait: "20 millis" as const },
{ id: "second", wait: "1 millis" as const }
]), ({ id, wait }) => Fx.at(id, wait))
const program = Effect.scoped(Fx.collectAll(ordered))
Effect.runPromise(program).then(console.log)
// ["first", "second"]: the one-millisecond inner is not started earlyOther public imports
These import paths expose the same declaration. Each page retains its own public name and signature.