Class: FlyzeStorageService
@flyze/lib-core-angular 1.0.0-alpha.34· latestDefined in: projects/lib-core-angular/src/lib/modules/storage/storage.service.ts:82
Reads, writes and deletes opaque JSON, sending each key to the storage location its path is routed to.
The only piece of this module application code touches. It is data-agnostic: it knows no models, no schema, and not which keys exist or what they mean. Callers own the meaning of a value; this service owns where it goes.
await storage.write('color-scheme', 'dark');const scheme = await storage.read<string>('color-scheme'); // 'dark', or nullRoutes come from FLYZE_STORAGE_ROUTES, and the longest matching prefix wins. A key no
route claims goes to localStorage, so an app that registers nothing gets a guarded
localStorage wrapper and nothing more.
The full key — prefix included — is passed to the provider unchanged. This service never rewrites keys; the providers namespace internally, which is what lets a route be re-pointed at a different provider without touching a stored entry or a call site.
A route is the seam another storage location arrives on. A provider that scopes values to the
signed-in user, or one backed by an API, is written in the app or in @flyze/lib-data-store —
never here — and takes over its route, optionally wrapping a built-in provider as its first-paint
cache. One registration changes; no call site does. That is also why this service must not be
“simplified” into a plain localStorage wrapper, and why the contract is async even though
localStorage is not.
Rationale: docs/decisions/0012-route-client-storage-by-key-path.md
Nothing here throws: every failure degrades to “not remembered”. See FlyzeStorageProvider.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FlyzeStorageService():
FlyzeStorageService
Returns
Section titled “Returns”FlyzeStorageService
Methods
Section titled “Methods”delete()
Section titled “delete()”delete(
key):Promise<void>
Defined in: projects/lib-core-angular/src/lib/modules/storage/storage.service.ts:122
Deletes the entry under a key. Deleting an absent key is not an error.
Parameters
Section titled “Parameters”string
The full key, including any route prefix.
Returns
Section titled “Returns”Promise<void>
Resolves once removed, or once the delete has been dropped.
read()
Section titled “read()”read<
T>(key):Promise<T>
Defined in: projects/lib-core-angular/src/lib/modules/storage/storage.service.ts:100
Reads the value stored under a key.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”string
The full key, including any route prefix.
Returns
Section titled “Returns”Promise<T>
The stored value, or null if absent, corrupt or unreadable.
The shape is not to be trusted — T is a convenience for the caller, not a guarantee, so
validate anything that a stale entry could break.
write()
Section titled “write()”write(
key,value):Promise<void>
Defined in: projects/lib-core-angular/src/lib/modules/storage/storage.service.ts:112
Writes a value under a key, replacing whatever was there.
Parameters
Section titled “Parameters”string
The full key, including any route prefix.
unknown
Any JSON-serializable value.
Returns
Section titled “Returns”Promise<void>
Resolves once stored, or once the write has been dropped — a provider that cannot store drops the value rather than reporting a failure.