Command
Intent: Encapsulate a request as an object to support undo, queues and logging.
When to use it
- Undo/redo
- Queued or scheduled actions
Example
Undo/redo stack in a design editor.
Code sketch (TypeScript)
interface Command { do(): void; undo(): void }
const history: Command[] = [];