Optional
scope: anyIWatch.addWatch()
implementation. Delegates to wrapped atom/cursor.
watch ID
watch function
Records given state in history. This method is only needed when manually managing snapshots, i.e. when applying multiple swaps on the wrapped atom directly, but not wanting to create an history entry for each change.
Optional
state: Tstate to record
DO NOT call this explicitly if using History.reset / History.swap etc.
If no state
is given, uses the wrapped atom's current state value (user code SHOULD always call without arg).
If recording succeeded, the History.EVENT_RECORD
event is emitted with the recorded state provided as event value.
Attempts to re-apply most recent value from future stack to atom and returns it if successful (i.e. there's a future).
Before the switch, first records the atom's current value into the history stack (to enable History.undo feature). Returns undefined
if there's no future (so sad!).
If redo was possible, the History.EVENT_REDO
event is emitted after the restoration with both the prev
and curr
(restored) states provided as event value (and object with these two keys). This allows for additional state handling to be executed, e.g. application of the "Command pattern". See History.addListener for registering event listeners.
Optional
scope: anyAttempts to re-apply most recent historical value to atom and returns it if successful (i.e. there's a history).
Before the switch, first records the atom's current value into the future stack (to enable History.redo feature). Returns undefined
if there's no history.
If undo was possible, the History.EVENT_UNDO
event is emitted after the restoration with both the prev
and curr
(restored) states provided as event value (and object with these two keys). This allows for additional state handling to be executed, e.g. application of the "Command pattern". See History.addListener for registering event listeners.
Generated using TypeDoc
Undo/redo history stack wrapper for atoms and cursors. Implements IAtom interface and so can be used directly in place and delegates to wrapped atom/cursor.
Remarks
Value changes are only recorded in history if
changed
predicate returns truthy value, or else by calling History.record directly. This class too implements theINotify
interface to support event listeners for History.undo, History.redo and History.record.