Abstract
An observable that emits the result of canRedo()
every time that value changes.
An observable that emits the result of canUndo()
every time that value changes.
Protected
maxThe maximum size of the history before discarding the oldest state. 0
means no limit.
An observable that emits the current state every time it changes.
Protected
Readonly
storeReturns the current undo state that was most recently pushed or applied. Calls to undo
will apply the state before this in teh stack, and redo
will apply the state after this.
Returns a view of the internal undo stack, from oldest to newest. Note that this contains states that would be applied by calls to both .undo()
and .redo
.
Protected
Abstract
applyReset the store to the given state.
The undoOrRedo
and stateToOverwrite
parameters can be useful e.g. if a scroll position is kept in the undo state. In such a case you want to change the scrolling so the user can see what just changed by undoing/redoing. To do that, set the scoll to what it was in stateToOverwrite
when undoing, and to what it is in stateToApply
when redoing.
Drops the state from the internal undo stack that would be applied by a call to .undo()
. This is useful e.g. if making multiple changes in a row that should be collapsed into a single undo state: call this first before pushing the new version.
Error when there is no such state (i.e. when canUndo()
returns false)
Protected
Abstract
extractReturn the information needed to reconstruct the given state. This will be passed to applyUndoState()
when the store should be reset to this state.
Protected
isAdd the current state to the undo history. Any states that could be reached using redo()
are discarded.
Optional
collectOptional
collectProtected
shouldUsed to determine whether .pushCurrentState()
actually does anything. Override this e.g. to prevent pushing a duplicate undo state using something like this:
protected shouldPush(state: UndoStateType) {
return equal(state, this.currentUndoState);
}
The maximum size of the history before discarding the oldest state.
0
means no limit.