variable / @typed/fx/Push

filterMapEffect

Effectfully maps each Fx output and emits only resulting Some values.

One mapper Effect runs per upstream value. Some(c) emits once, None emits nothing, and failures join the output error channel. Sequential sources retain order; the input Sink remains unchanged.

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

Import

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

Signatures

export declare const filterMapEffect: {
    <B, C, E3, R3>(f: (b: B) => Effect.Effect<Option.Option<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<Option.Option<C>, E3, R3>): Push<A, E, R, C, E2 | E3, R2 | R3>;
};

Why

This models service-backed lookup where absence is an ordinary filtered result but operational failure must remain observable.

Ownership and lifetime

Mapper effects are owned and interrupted by the output subscription. Their services join R2 and failures join E2; the combinator adds no independent buffer or resource.

Examples

import { Effect, Option } 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("one"))
const ids = Push.filterMapEffect(push, (name) => Effect.succeed(name === "one" ? Option.some(1) : Option.none()))

Other public imports

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

Source