Skip to content

@stainless-code/persist

Hydration-aware persistence for any reactive store — zero-dep persistSource core; codecs, backends, cross-tab transport, source + framework hydration adapters ship as opt-in recipes

angular-persist

55 linesSource

Gate Angular UI on Persist hydration with useHydrated (readonly Signal). Call inside an injection context; use when avoiding flash of default state on async backends.

Angular hydration gate

@stainless-code/persist/frameworks/angular returns a readonly Signal<boolean>. A real signal needs an injection context (effect()); null/undefined returns a shared signal(true) without effect().

Install

shell
bun add @stainless-code/persist @angular/core

Peer: @angular/core >=17.0.0.

Minimal wiring

ts
import { useHydrated } from "@stainless-code/persist/frameworks/angular";

export class PrefsComponent {
  hydrated = useHydrated(prefsHydration);
}
html
@if (hydrated()) {
<prefs-panel />
} @else {
<skeleton />
}

Common mistakes

  • Calling outside injection context.
  • Treating the signal as store state.
  • SSR / null signal — both surface as hydrated true.

API surface

  • useHydrated(signal) → Signal<boolean> (readonly)