Interface: UseAmnesiaResult
Defined in: use.ts:23
Hook returning the current Amnesia state plus stable action callbacks.
The returned object is reconstructed on every store mutation but the
action functions (push, amend, undo, redo, clear) remain referentially
stable across renders, so they can be used in useEffect deps without
causing re-runs.
The result also carries scopeId so consumers can render which scope a
snapshot describes (useful for "Undo (canvas)" toolbar labels).
Extends
Properties
amend
amend: (
patch) =>Promise<number|null>
Defined in: use.ts:29
Amend the most recent entry. See Amnesia.amend.
Parameters
| Parameter | Type |
|---|---|
patch | AmendPatch |
Returns
Promise<number | null>
canRedo
readonlycanRedo:boolean
Defined in: types.ts:165
Convenience flag — equivalent to future.length > 0.
Inherited from
canUndo
readonlycanUndo:boolean
Defined in: types.ts:162
Convenience flag — equivalent to past.length > 0.
Inherited from
clear
clear: () =>
void
Defined in: use.ts:46
Drop both stacks of this scope. See Amnesia.clear.
Returns
void
epoch
readonlyepoch:number
Defined in: types.ts:185
Monotonic counter that bumps only on clear() and provider unmount
(dispose()). Unlike version, incidental pushes / undos / redos do
not advance it.
Used internally by async operations as an abort token: an in-flight
await whose epoch snapshot disagrees with the current value resolves
to a stale-drop and is reported via onError({ phase: "stale" }).
Application code can also subscribe to epoch to detect "the document
changed underneath me" without re-rendering on every keystroke.
Inherited from
future
readonlyfuture: readonlyHistoryEntry[]
Defined in: types.ts:159
Entries available to redo(), with the next-redo entry at the end.
Inherited from
past
readonlypast: readonlyHistoryEntry[]
Defined in: types.ts:154
Entries available to undo(), oldest at index 0 and newest at the
end. Same ordering as a typical "history list" UI.
Inherited from
pending
readonlypending:boolean
Defined in: types.ts:195
true while at least one push / undo / redo has an unresolved
Promise in flight. Synchronous handlers complete before any subscriber
observes pending: true.
Concurrent calls while pending === true resolve to null immediately
and are reported via onError({ phase: "busy" }).
Inherited from
push
push: (
command,options?) =>Promise<number|null>
Defined in: use.ts:27
Push a new command. See Amnesia.push.
Parameters
| Parameter | Type |
|---|---|
command | Command |
options? | PushOptions |
Returns
Promise<number | null>
redo
redo: () =>
Promise<number|null>
Defined in: use.ts:33
Redo the most recent future entry. See Amnesia.redo.
Returns
Promise<number | null>
scopeId
scopeId:
string
Defined in: use.ts:25
The scope id this snapshot is bound to.
transaction
transaction: {(
work):Promise<number|null>; (label,work):Promise<number|null>; }
Defined in: use.ts:38
Run a series of pushes as a single composite entry. See Amnesia.transaction.
Call Signature
(
work):Promise<number|null>
Parameters
| Parameter | Type |
|---|---|
work | (tx, signal) => void | Promise<void> |
Returns
Promise<number | null>
Call Signature
(
label,work):Promise<number|null>
Parameters
| Parameter | Type |
|---|---|
label | string |
work | (tx, signal) => void | Promise<void> |
Returns
Promise<number | null>
undo
undo: () =>
Promise<number|null>
Defined in: use.ts:31
Undo the most recent past entry. See Amnesia.undo.
Returns
Promise<number | null>
version
readonlyversion:number
Defined in: types.ts:171
Monotonic version counter incremented on every mutation. Useful for
cache keys or useEffect dependency arrays.