function / @typed/fx

RefSubject.Service

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

Package version
2.0.0-beta.7
Category
Services
Since
1.18.0
Member of
RefSubject

Import

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

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