Skip to main content

Interface: AmnesiaStoreOptions

Defined in: types.ts:304

Lower-level configuration consumed by createAmnesiaStore. Hooks receive the entry only — there is no scope concept at the store level.

AmnesiaProviderOptions extends this for the React provider with scopeId-aware hooks; the provider api binds scopeId before passing options to the underlying store.

Properties

capacity?

optional capacity?: number

Defined in: types.ts:312

Maximum number of entries retained on the past stack. When the limit is reached, the oldest entry is dropped on every new push.

Defaults to 100. Set to Infinity to disable, but be aware closures may retain large amounts of memory.


coalesceWindowMs?

optional coalesceWindowMs?: number

Defined in: types.ts:320

Maximum time (in milliseconds) between two pushes that share a non-empty coalesceKey for them to merge into a single entry.

Defaults to 400.


metaTransform?

optional metaTransform?: (meta) => Record<string, unknown> | undefined

Defined in: types.ts:369

Sanitizer applied to meta before it is exposed in the public snapshot or passed to lifecycle hooks. Use this to redact sensitive fields without forcing every call site to remember the rule.

Only invoked when meta is defined. The return value replaces meta in the public HistoryEntry; returning undefined strips it.

The transform should be pure and stable — it runs every time the snapshot is rebuilt and every time a hook is fired.

Parameters

ParameterType
metaRecord<string, unknown>

Returns

Record<string, unknown> | undefined


onAmend?

optional onAmend?: (entry) => void

Defined in: types.ts:344

Lifecycle hook fired after a successful amend updates the most recent past entry.

Parameters

ParameterType
entryHistoryEntry

Returns

void


onClear?

optional onClear?: () => void

Defined in: types.ts:356

Lifecycle hook fired after clear() on a scope that actually had something to clear. (No-op clears do not fire.)

Returns

void


onError?

optional onError?: AmnesiaErrorHandler

Defined in: types.ts:326

Custom error reporter for failures inside redo / undo. See AmnesiaErrorHandler.


onPush?

optional onPush?: (entry) => void

Defined in: types.ts:338

Lifecycle hook fired after a successful push commits a new entry. Coalesce-merges do not fire this — only the first push of a coalesce burst counts as a logical user action.

Hook payloads are dispatched after the snapshot is updated and after subscribers have been notified, so handlers see a quiescent store. A throw inside the handler is caught and ignored. The entry's meta (when present) has already been passed through metaTransform.

Parameters

ParameterType
entryHistoryEntry

Returns

void


onRedo?

optional onRedo?: (entry) => void

Defined in: types.ts:350

Lifecycle hook fired after a successful redo.

Parameters

ParameterType
entryHistoryEntry

Returns

void


onUndo?

optional onUndo?: (entry) => void

Defined in: types.ts:347

Lifecycle hook fired after a successful undo.

Parameters

ParameterType
entryHistoryEntry

Returns

void