Adapter Contract
Reference for NusmAdapter, browser adapter options, events, and pacing.
Built-in adapter factories
function createLocalStorageAdapter(
options?: StorageAdapterOptions,
): NusmAdapter;
function createSessionStorageAdapter(
options?: StorageAdapterOptions,
): NusmAdapter;
function createIndexDbAdapter(options?: IndexDbAdapterOptions): NusmAdapter;NusmAdapter
Prop
Type
AdapterEvent
type AdapterEventType = "set" | "remove" | "clear";Prop
Type
Provide a key for set and remove. An adapter-wide clear can omit it.
subscribe represents external adapter changes. nusm attaches it whenever the
adapter provides it. Authenticated browser synchronization is configured
independently through sync and does not replace adapter subscriptions.
Because built-in Web Storage adapters subscribe to browser events, persisted
stores also require a shape-specific sync.validator even without a browser
synchronization source. The validator protects memory from adapter-originated
external values as well as authenticated peer updates.
NusmPacerConfig
type NusmPacerConfig =
| false
| {
wait?: number;
maxWait?: number;
leading?: boolean;
trailing?: boolean;
};false bypasses the debouncer. The current runtime forwards wait, leading, and trailing to the AsyncDebouncer; maxWait remains in the public type but is not forwarded yet.
StorageAdapterOptions
Used by createLocalStorageAdapter and createSessionStorageAdapter:
Prop
Type
StorageLike
Prop
Type
key and length enable getAllKeys; clear enables adapter clearing.
IndexDbAdapterOptions
Prop
Type
See Custom Adapters for implementation guidance and invariants.