signalHistory
is a helper function that allows you to track the history of a signal and provides undo/redo functionality.
Usage
signalHistory
needs a signal as an argument and returns an object with the following properties:
history
: A signal that represents the history of the source signal.
undo
: A function that undoes the last change to the source signal.
redo
: A function that redoes the last undone change to the source signal.
reset
: A function that resets the history to the current state.
clear
: A function that clears the history.
canUndo
: A signal that indicates if undo is possible.
canRedo
: A signal that indicates if redo is possible.
You can pass custom options to the function.
Should Record
You can pass a shouldRecord
function to the signalHistory
function.