Import
import { Sink } from "@typed/fx";Access Sink.filter 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
export declare function filter<A, E, R>(sink: Sink<A, E, R>, f: (a: A) => boolean): Sink<A, E, R>;Why
Predicate filtering narrows consumer traffic without changing the producer.
Ownership and lifetime
The predicate runs synchronously in arrival order. Matching values invoke the wrapped sink once; non-matches invoke it zero times. The adapter acquires no resources.
Examples
import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
import { Fx } from "@typed/fx"
const program = Effect.gen(function* () {
const sink = Sink.make(
(cause) => Effect.void,
(value: number) => Effect.sync(() => console.log("Positive:", value))
)
// Only pass through positive numbers
const filtered = Sink.filter(sink, (n) => n > 0)
yield* Fx.fromIterable([-2, -1, 0, 1, 2]).run(filtered)
// Output: "Positive: 1", "Positive: 2"
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.