Import
import { Sink } from "@typed/fx";Access Sink.filterMap 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 filterMap<A, E, R, B>(sink: Sink<A, E, R>, f: (b: B) => Option.Option<A>): Sink<B, E, R>;Why
Selection and transformation happen at the consumer boundary without constructing another Fx.
Ownership and lifetime
Inputs are inspected synchronously in arrival order. Some invokes the wrapped sink once;
None invokes it zero times. The adapter acquires no resources and failures pass through.
Examples
import { Effect, Option } 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("Even:", value))
)
// Only pass through even numbers
const filtered = Sink.filterMap(sink, (n: number) =>
n % 2 === 0 ? Option.some(n) : Option.none()
)
yield* Fx.fromIterable([1, 2, 3, 4, 5]).run(filtered)
// Output: "Even: 2", "Even: 4"
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.