Undo/redo functionality with history tracking using TimeTravelPlugin
Make changes, then undo/redo or jump to any point in history!
import { createSignal } from 'signalforge/core';
import { TimeTravelPlugin } from 'signalforge/plugins';
const count = createSignal(0);
const timeTravel = new TimeTravelPlugin();
// Track signal changes
timeTravel.trackSignal(count, 'counter');
// Make changes
count.set(1);
count.set(2);
count.set(3);
// Time travel!
timeTravel.undo('counter'); // back to 2
timeTravel.undo('counter'); // back to 1
timeTravel.redo('counter'); // forward to 2
// Jump to specific state
timeTravel.jumpTo('counter', 0); // back to initial state
// Check history
const history = timeTravel.getHistory('counter');
console.log(history); // [{ value: 0, timestamp: ... }, ...]Undo/redo for document editing
Revert drawing actions step by step
Navigate back through multi-step forms
Replay state changes to find bugs
Keep last 50-100 states to avoid memory issues.
Deep clone objects to prevent accidental mutations.
Built-in plugin for automatic undo/redo support.
Group multiple changes into one history entry.