Import
import { getOrElse } from "@typed/fx/RefSubject";Signatures
export declare const getOrElse: {
<A>(fallback: () => A): <E, R>(ref: Computed<Option.Option<A>, E, R> | Filtered<A, E, R>) => Computed<A, E, R>;
<A, E, R>(ref: Computed<Option.Option<A>, E, R> | Filtered<A, E, R>, fallback: () => A): Computed<A, E, R>;
};Why
Returns a Computed that yields the value inside the Option, or the fallback when None.
Works with Computed<Option<A>> (e.g. from fromOption / fromNullable) and with
Filtered<A>. Current reads and pushed versions use the same derivation, preventing snapshot
and subscription behavior from diverging.
Ownership and lifetime
The returned Computed never fails for absence: None or an absent Filtered value invokes
fallback. It preserves only the input’s declared E and R; the pure fallback adds no failure,
service, subscription, or retained value.
Examples
import { Effect, Option } from "effect"
import * as RefSubject from "@typed/fx/RefSubject"
const program = Effect.gen(function* () {
const ref = yield* RefSubject.fromOption(Option.some(42))
const withDefault = RefSubject.getOrElse(ref, () => 0)
expect(yield* withDefault).toBe(42)
const empty = yield* RefSubject.fromNullable(null)
const fallback = RefSubject.getOrElse(empty, () => 99)
expect(yield* fallback).toBe(99)
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.