UNPKG

@stainless-code/persist

Version:

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

34 lines (33 loc) • 1.47 kB
import { f as StateStorage, u as PersistStorage } from "../persist-core-B649IGlX.mjs"; import { AsyncStorage } from "@react-native-async-storage/async-storage"; //#region src/adapters/backends/async-storage.d.ts /** * `StateStorage` over React Native `AsyncStorage` — fully async, string-wire. * Pass a custom `AsyncStorage` instance (e.g. `getLegacyStorage()`) to * namespace away from the default; defaults to the module singleton. * * @example * ```ts * import { asyncStorageStateStorage } from "@stainless-code/persist/backends/async-storage"; * * const storage = asyncStorageStateStorage(); * ``` */ declare function asyncStorageStateStorage(storage?: AsyncStorage): StateStorage; /** * Build a JSON-encoded `PersistStorage` over React Native `AsyncStorage`. * Async backend → hydration can't settle before first render, so `useHydrated` * gating is mandatory (the `./frameworks/react` / `./frameworks/solid` / `./frameworks/vue` / `./frameworks/svelte` adapters). * * @example * ```ts * import { createAsyncStorage } from "@stainless-code/persist/backends/async-storage"; * import { persistStore } from "@stainless-code/persist/sources/tanstack-store"; * * const storage = createAsyncStorage<Prefs>()!; * persistStore(store, { name: "app:prefs:v1", storage }); * ``` */ declare function createAsyncStorage<S>(storage?: AsyncStorage): PersistStorage<S> | undefined; //#endregion export { asyncStorageStateStorage, createAsyncStorage };