Pattern: Undo/Redo
Pattern: Undo / Redo
Build undo/redo functionality with a history stack state machine.
Overview
Undo/redo is a classic stack pattern that maps naturally to a state machine with history states and a stack context.
Key Concepts
States: canUndo / canRedo / atHead / atTail
Stack as context with pointer
Guard: canUndo, canRedo
Actions: push, undo, redo, clear
Related Pages
Undo/Redo → Forms — Undoable form edits
Undo/Redo → Drag and Drop — Undoable reordering
Case Study: Document Editor — Version history
TODO
Add bounded stack machine (max N entries)
Add group operations (atomic undo)
Add visual history timeline
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime
Powered by Seed HypermediaOpen App