Import
import { RefSubject } from "@typed/fx";Access RefSubject.hydrate 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 hydrate<S extends Schema.Codec<any, string, any, any>, E = never, R = never>(schema: S, effect: HydrationInput<NoInfer<Schema.Schema.Type<S>>, E, R>, options: HydrateOptions<Schema.Schema.Type<S>> & {
readonly name: string;
}): HydrateEffect<S, E, R>;export declare function hydrate<S extends Schema.Top, E = never, R = never>(schema: S, effect: HydrationInput<NoInfer<Schema.Schema.Type<S>>, E, R>, options?: HydrateOptions<Schema.Schema.Type<S>> & {
readonly name?: undefined;
}): HydrateEffect<S, E, R>;Why
Creates state whose server value is Schema-encoded and whose browser value is Schema-decoded before the initializer resumes.
Ownership and lifetime
The creation Effect requires Scope; that Scope owns initializer subscriptions and deferred server/client coordination. Schema errors and codec services remain typed.
Values, Effects, Effect Streams, and Fx are accepted as initializers. A named string codec uses
its own data-* attribute; unnamed values share the versioned data-typed-refsubject envelope.
See {@link https://effect.website/docs/schema/introduction/ Effect Schema} for the codec and
service model used by this boundary.
Synchronous configuration errors
Supplying an empty name, the reserved typed-refsubject name, or a name containing characters
forbidden in an HTML attribute throws TypeError immediately while hydrate is called. These
programmer errors are outside the returned Effect’s typed error channel. Schema decoding and
encoding failures remain Schema.SchemaError, and codec requirements remain typed services.
Examples
import { Effect, Schema } from "effect"
import * as Hydration from "@typed/fx/RefSubject"
import { RefSubject } from "@typed/fx"
const attributes = Effect.scoped(Effect.gen(function* () {
const count = yield* Hydration.hydrate(Schema.FiniteFromString, 0, { name: "count" })
yield* RefSubject.update(count, (value) => value + 1)
return yield* count[Hydration.HydrationRefTypeId].toAttributes
}))Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.