variable / @typed/fx/Sink

dropAfter

Runs a producer callback until the first matching value has been forwarded.

Package version
2.0.0-beta.7
Category
Stopping delivery
Since
1.0.0

Import

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

Signatures

export declare const dropAfter: {
    <A, E, R, R2>(sink: Sink<A, E, R>, predicate: Predicate<A>, f: (sink: Sink<A, E, R>) => Effect.Effect<unknown, E, R2>): Effect.Effect<void, never, R | R2>;
};

Why

Unlike a filtering operation, dropAfter includes the boundary value and then terminates producer work normally.

Ownership and lifetime

Values are forwarded in order through the first predicate match, then early exit completes and aborts the callback fiber. Callback failure is caught and sent to the original sink. The predicate is synchronous; thrown exceptions are defects.

Examples

import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const target = Sink.make(Effect.logError, Effect.log)
const program = Sink.dropAfter(target, (n: number) => n >= 10, (limited) => limited.onSuccess(10))

Other public imports

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

Source