interface / @typed/fx

RefSubject.HydrationRef

Defines the hydration ref state contract.

Package version
2.0.0-beta.13
Category
Hydration protocol
Since
2.0.0
Member of
RefSubject

Import

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

Access RefSubject.HydrationRef 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 interface HydrationRef<E = never, R = never> {
    (element: HydrationElement): Effect.Effect<void, never, R | Scope.Scope>;
    readonly [HydrationRefTypeId]: {
        readonly members: ReadonlyArray<HydrationMember>;
        readonly server: Effect.Effect<void>;
        readonly toAttributes: Effect.Effect<ReadonlyArray<HydrationAttribute>, E, R>;
    };
}

Why

Makes a state boundary callable with an attribute host while also exposing server serialization as ordinary typed Effects.

Ownership and lifetime

HydrationRef is a contract and performs no acquisition. Implementations retain the errors, services, interruption, and Scope requirements expressed by its members.

Call signatures

Restores every member from a DOM-compatible attribute host.

Call signatures: Why

Reads and removes encoded attributes, decodes them with each member’s Schema, and completes the deferred client initializer before ordinary state observation resumes.

Call signatures: Ownership and lifetime

Running the Effect requires Scope for deferred restoration and member subscriptions. Missing attributes resume the original initializer; Schema failures and codec services remain on the member metadata rather than becoming DOM exceptions.

Property: [[computed:[HydrationRefTypeId]]]

Exposes the members and Effects used for serialization and restoration.

Property: [[computed:[HydrationRefTypeId]]]: Why

Keeps server serialization discoverable without changing the RefSubject prototype or requiring a renderer-specific wrapper.

Property: [[computed:[HydrationRefTypeId]]]: Ownership and lifetime

The operation starts only when its Effect is run. Any subscription or deferred hydration work is finalized by the required Scope.

Other public imports

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

Source