variable / @typed/fx

Sink.filterMapEffect

Runs an Effect for each input and forwards its optional successful value.

Package version
2.0.0-beta.13
Category
Selecting inputs
Since
1.0.0
Member of
Sink

Import

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

Access Sink.filterMapEffect 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 const filterMapEffect: {
    <B, A, E2, R2>(f: (b: B) => Effect.Effect<Option.Option<A>, E2, R2>): <E, R>(sink: Sink<A, E | E2, R>) => Sink<B, E | E2, R | R2>;
    <A, E, R, B, E2, R2>(sink: Sink<A, E | E2, R>, f: (b: B) => Effect.Effect<Option.Option<A>, E2, R2>): Sink<B, E | E2, R | R2>;
};

Why

Service-backed validation, selection, and transformation can happen in one consumer adapter.

Ownership and lifetime

Each input runs one Effect. Some invokes the sink once, None zero times, and failure is routed as a Cause. Invocation order and concurrency are controlled by the producer; services and interruption remain explicit in the returned sink.

Examples

import { Effect, Option } from "effect"
import * as Sink from "@typed/fx/Sink"
const sink = Sink.filterMapEffect(Sink.make(Effect.logError, Effect.log), (n: number) =>
  Effect.succeed(n > 0 ? Option.some(n) : Option.none()))

Other public imports

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

Source