function / @typed/fx/RefSubject

fromStream

Creates a RefSubject that tracks the latest value emitted by an Effect Stream.

Package version
2.0.0-beta.7
Category
Source adapters
Since
1.18.0

Import

import { fromStream } from "@typed/fx/RefSubject";

Signatures

export declare function fromStream<A, E, R>(stream: Stream.Stream<A, E, R>, options?: RefSubjectOptions<A>): Effect.Effect<RefSubject<A, E>, never, R | Scope.Scope>;

Why

Bridges a pull-based Stream into renderer-independent state: each emitted value enters the RefSubject’s serialized commit path, while a stream failure becomes the ref’s current and pushed failure.

Ownership and lifetime

Construction forks stream consumption immediately into the RefSubject’s private Scope and cannot fail. R is required while constructing that fiber; closing the outer Scope interrupts it. Before the first value or failure, a current read waits for initialization. Later reads and pushes expose E.

Other public imports

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

Source