variable / @typed/fx/Fx

delimit

Wraps an Fx with a start and end value.

Package version
2.0.0-beta.7
Category
Combining sources
Since
1.0.0

Follow one execution

The start and end values bracket one source run.

Fx timelinedelimit(start, end)delimit
Operatordelimit(start, end)
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.

before is emitted once, followed by every source success or delivered source failure, then after once when the source run Effect returns. Interruption or a defect suppresses after; this is Sink sequencing, not Effect.ensuring. No resource is acquired and source requirements are kept.

Source implementation · Learn the surrounding model

Compare all Fx timelines →

Import

import { delimit } from "@typed/fx/Fx";

Signatures

export declare const delimit: {
    <B, C>(before: B, after: C): <A, E, R>(fx: Fx<A, E, R>) => Fx<A | B | C, E, R>;
    <A, E, R, B, C>(fx: Fx<A, E, R>, before: B, after: C): Fx<A | B | C, E, R>;
};

Why

delimit composes {@link prepend} and {@link append} for protocols whose normal run must be bracketed by values rather than resource finalizers.

Ownership and lifetime

before is emitted once, followed by every source success or delivered source failure, then after once when the source run Effect returns. Interruption or a defect suppresses after; this is Sink sequencing, not Effect.ensuring. No resource is acquired and source requirements are kept.

Examples

import { Fx } from "@typed/fx"
import { Effect } from "effect"

const framed = Fx.delimit(Fx.fromIterable([1, 2]), "[", "]")
Effect.runPromise(Fx.collectAll(framed)).then(console.log)
// ["[", 1, 2, "]"]

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source