Import
import { RefSubject } from "@typed/fx";Access RefSubject.filterMapEffect through the imported RefSubject 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 filterMapEffect: {
<A, B, E2, R2>(f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>): {
<E, R>(ref: RefSubject<A, E, R> | Computed<A, E, R>): Filtered<B, E | E2, R | R2>;
<E, R>(ref: Filtered<A, E, R>): Filtered<B, E | E2, R | R2>;
<R0, E0, B, E, R, E2, R2>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>): Filtered<B, E0 | E | E2, R0 | R2>;
};
<A, E, R, B, E2, R2>(ref: RefSubject<A, E, R> | Computed<A, E, R> | Filtered<A, E, R>, f: (a: A) => Effect.Effect<Option.Option<B>, E2, R2>): Filtered<B, E | E2, R | R2>;
<R0, E0, A, E, R, B, E2, R2, R3, E3>(versioned: Versioned.Versioned<R0, E0, A, E, R, A, E2, R2>, f: (a: A) => Effect.Effect<Option.Option<B>, E3, R3>): Filtered<B, E0 | E | E2 | E3, R0 | R2 | R3 | Exclude<R, Scope.Scope>>;
};Why
Filters and transforms a RefSubject, Computed, or Filtered using an Effectful function
that returns an Option. Current reads and pushed versions use the same derivation, preventing
snapshot and subscription behavior from diverging.
Ownership and lifetime
The filter map effect view retains no independent value. Its Effect read fails with NoSuchElement while absent; the observing Scope owns and finalizes its Fx subscription.
Examples
import { Effect, Option } from "effect"
import * as RefSubject from "@typed/fx/RefSubject"
const program = Effect.gen(function* () {
const numbers = yield* RefSubject.make([1, 2, 3, 4, 5])
// Find the first even number
const firstEven = RefSubject.filterMapEffect(numbers, (arr) =>
Effect.succeed(Option.fromNullable(arr.find((n) => n % 2 === 0)))
)
const value = yield* firstEven
console.log(value) // 2
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.