variable / @typed/fx/Push

filterMapInputEffect

Effectfully transforms an input and forwards only a resulting Some value.

Calling onSuccess(value) invokes f(value) immediately to construct an Effect; allocation and throws happen before an acknowledgment is returned. Running that acknowledgment later executes the constructed Effect in the caller’s fiber. Some(a) produces one Sink callback, None none, and failure sends its full Cause to the Sink failure callback. Concurrent calls are not serialized.

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

Import

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

Signatures

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

Why

This is the input-boundary form for service-backed lookup or validation where absence is expected but failure remains meaningful.

Ownership and lifetime

Mapper Effect construction is eager; execution belongs to the fiber that runs the returned acknowledgment and can be interrupted there. Mapper requirements join the Sink input requirements; its E is handled through the same failure callback. The output Fx is untouched.

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 known = Push.filterMapInputEffect(
  Push.make(Sink.make(() => Effect.void, (_n: number) => Effect.void), Fx.empty),
  (text: string) => Effect.succeed(text === "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