variable / @typed/fx

Push.filterInputEffect

Effectfully decides whether each successful input reaches the Sink.

Calling onSuccess(value) invokes f(value) immediately to construct the predicate Effect; allocation and throws happen before an acknowledgment is returned. Running the acknowledgment later executes that Effect in the caller’s fiber. true forwards one value, false none, and failure sends its Cause to the Sink failure callback. Calls are not serialized; the producer controls order and concurrency. Output behavior is unchanged.

Package version
2.0.0-beta.7
Category
Selecting inputs
Since
1.0.0
Member of
Push

Import

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

Access Push.filterInputEffect through the imported Push 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 filterInputEffect: {
    <A, R3, E>(f: (a: A) => Effect.Effect<boolean, E, R3>): <R, B, E2, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R | R3, B, E2, R2>;
    <A, E, R, B, E2, R2, R3>(push: Push<A, E, R, B, E2, R2>, f: (a: A) => Effect.Effect<boolean, E, R3>): Push<A, E, R | R3, B, E2, R2>;
};

Why

This supports authorization and service-backed eligibility checks directly at the consumer boundary.

Ownership and lifetime

Predicate Effect construction is eager; its execution and downstream callback belong to the fiber that runs the returned acknowledgment, whose interruption stops them. Predicate services join input R; typed E is consumed through the Sink failure channel.

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 even = Push.filterInputEffect(
  Push.make(Sink.make(() => Effect.void, (_n: number) => Effect.void), Fx.empty),
  (n) => Effect.succeed(n % 2 === 0)
)

Other public imports

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

Source