function / @typed/fx/RefSubject

Service

Creates a Context-backed RefSubject service facade and Layer constructors.

Package version
2.0.0-beta.13
Category
Services
Since
1.18.0

Import

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

Signatures

export declare function Service<Self, A, E = never>(): <const Id extends string>(id: Id) => RefSubject.Class<Self, Id, A, E>;

Why

The returned class is simultaneously a service tag, a current-value Effect, an Fx source, and a writable RefSubject facade. This lets consumers read, observe, and update renderer-independent state without manually retrieving the underlying service from Context.

Ownership and lifetime

Calling Service is pure. layer installs an existing scoped RefSubject; make constructs one and installs it in a Layer. The Layer Scope owns the subject and its initializer subscription. Reads and pushes expose the declared E channel; construction requirements remain on the Layer, while consumers require only the generated Self service.

Other public imports

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

Source