variable / @typed/fx/Push

mapEffect

Effectfully transforms each Fx output value.

The mapper runs once per upstream value and emits one result on success, in upstream order for a sequential source. Its typed failures join E2; its required services join R2. The input side is unchanged.

Package version
2.0.0-beta.7
Category
Transforming outputs
Since
1.0.0

Import

import { mapEffect } from "@typed/fx/Push";

Signatures

export declare const mapEffect: {
    <B, C, E3, R3>(f: (b: B) => Effect.Effect<C, E3, R3>): <A, E, R, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, C, E2 | E3, R2 | R3>;
    <A, E, R, B, E2, R2, C, E3, R3>(push: Push<A, E, R, B, E2, R2>, f: (b: B) => Effect.Effect<C, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3>;
};

Why

Use this for output enrichment that needs Effect services or can fail while keeping input handling independent.

Ownership and lifetime

Each mapper Effect runs inside the output subscription and is interrupted with it. No work starts before run; cleanup belongs to the upstream Fx and mapper effects. mapEffect itself introduces no separate buffer or long-lived fiber.

Examples

import { Effect } from "effect"
import * as Fx from "@typed/fx/Fx"
import * as Push from "@typed/fx/Push"
import * as Sink from "@typed/fx/Sink"

const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.succeed(2))
const doubled = Push.mapEffect(push, (n) => Effect.succeed(n * 2))

Other public imports

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

Source