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
Member of
RefSubject

Import

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

Access RefSubject.fromStream 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 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