variable / @typed/fx/Push

filterEffect

Effectfully decides which Fx output values are emitted.

Each upstream value runs one predicate. true emits that value, false emits none, and predicate failures join the output error channel. For a sequential source the predicate is acknowledged before the next delivery, preserving order; the input side is unchanged.

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

Import

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

Signatures

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

Why

Use this when an observed event needs an Effect service or fallible check before it is visible downstream.

Ownership and lifetime

Predicate effects run inside and are interrupted with the output subscription. Their E3 failures and R3 services join the Fx channels. No separate queue or persistent fiber is introduced.

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.fromIterable([1, 2]))
const positive = Push.filterEffect(push, (n) => Effect.succeed(n > 0))

Other public imports

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

Source