interface / @typed/fx

Sink.Sink.WithEarlyExit

A sink that can ask its producer callback to stop early.

Package version
2.0.0-beta.13
Category
Stopping delivery
Since
1.0.0
Member of
Sink.Sink

Import

import { Sink } from "@typed/fx";

Access Sink.Sink.WithEarlyExit through the imported Sink export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

interface WithEarlyExit<A, E, R> extends Sink<A, E, R> {
    readonly earlyExit: Effect<void>;
}

Why

Bounded consumers such as slice and dropAfter need to end production without encoding termination as a typed failure.

Ownership and lifetime

earlyExit completes the surrounding consumer effect. Further callback deliveries are ignored; interruption and cleanup remain owned by the surrounding producer effect.

Property: earlyExit

Completes the surrounding early-exit consumer and suppresses later deliveries.

Property: earlyExit: Why

Normal bounded completion remains distinct from typed producer failure.

Property: earlyExit: Ownership and lifetime

The surrounding withEarlyExit execution owns this Effect; running it aborts its callback fiber.

Examples

import { Effect } from "effect"
import type * as Sink from "@typed/fx/Sink"
const stop = (sink: Sink.Sink.WithEarlyExit<unknown, never, never>) => sink.earlyExit

Other public imports

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

Source