variable / @typed/fx

Sink.mapEffect

Runs an Effect for each input and forwards its successful value to the sink.

Package version
2.0.0-beta.7
Category
Transforming inputs
Since
1.0.0
Member of
Sink

Import

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

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

Why

Consumer-side adaptation can use services and typed failure without creating an intermediate Fx.

Ownership and lifetime

One transition Effect runs per callback invocation. Its success is forwarded once; its complete failure Cause is sent to onFailure. Calls themselves are not serialized by this adapter, so ordering follows the invoking producer. Services join the sink requirements; interruption is local to each callback Effect.

Examples

import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const numbers = Sink.mapEffect(Sink.make(Effect.logError, Effect.log), (text: string) =>
  Effect.succeed(Number(text)))

Other public imports

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

Source