function / @typed/fx

RefSubject.hydrateAll

Combines hydrated refs into one serialization and restoration boundary.

Package version
2.0.0-beta.7
Category
Hydration construction
Since
2.0.0
Member of
RefSubject

Import

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

Access RefSubject.hydrateAll 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 hydrateAll<const Refs extends readonly [
    HydratedRefSubject.Any,
    ...HydratedRefSubject.Any[]
]>(...refs: Refs): HydrationRef<HydratedRefSubject.HydrationError<Refs[number]>, HydratedRefSubject.HydrationServices<Refs[number]>>;

Why

Combines member metadata so several refs serialize and restore as one boundary while retaining each member’s errors and codec services.

Ownership and lifetime

The combined boundary acquires nothing and delegates lifetime to its member refs. Encoding or decoding retains the members’ Schema errors and services.

Named attributes must be unique. Unnamed members are encoded together and restored as a group, so normal initializers cannot race ahead of a partially decoded envelope.

Synchronous configuration errors

Combining two named refs whose normalized data-* attribute names are equal throws TypeError immediately while hydrateAll is called. This duplicate-name check is a configuration error, not a typed Schema failure. Member encoding and decoding errors remain Schema.SchemaError, and their codec services remain visible in the returned HydrationRef.

Examples

import { Effect, Schema } from "effect"
import * as Hydration from "@typed/fx/RefSubject"

const attributes = Effect.scoped(Effect.gen(function* () {
  const count = yield* Hydration.hydrate(Schema.Finite, 0)
  const status = yield* Hydration.hydrate(Schema.String, "ready")
  const state = Hydration.hydrateAll(count, status)
  return yield* state[Hydration.HydrationRefTypeId].toAttributes
}))

Other public imports

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

Source