BrowserPersistence unstable
IndexedDB-backed persistence layers for browser Effect programs.
This module provides a low-level BackingPersistence layer and a higher-level
Persistence layer that store object values in IndexedDB. Values are stored
by persistence store id and key, and reads check TTL expiration before
returning stored data. The database name can be customized and defaults to
"effect_persistence".
Layers
layerBackingIndexedDb
unstableCreates a BackingPersistence layer backed by IndexedDB, optionally using the provided database name.
Details
The database name defaults to "effect_persistence". Entries are stored by
persistence store id and key in a shared object store, and TTL expiration is
checked when values are read.
Gotchas
Building the layer can fail with PersistenceError if IndexedDB cannot be opened.
Acquisition can be interrupted while waiting for an open request.
Connections close on versionchange so other tabs can upgrade or delete the
database. Store operations report PersistenceError for IndexedDB request,
transaction, quota, and structured-clone failures.
See
- layerIndexedDb for providing the higher-level
Persistenceservice
Signature
declare function layerBackingIndexedDb(options?: { readonly database?: string;}): Layer<BackingPersistence, PersistenceError>layerIndexedDb
unstableCreates a Persistence layer backed by IndexedDB, optionally using the provided database name.
Details
Building the layer can fail with PersistenceError if IndexedDB cannot be opened.
The database name defaults to "effect_persistence".
See
- layerBackingIndexedDb for connection lifecycle and store failure behavior
Signature
declare function layerIndexedDb(options?: { readonly database?: string;}): Layer<Persistence, PersistenceError>