Overview
A bounded undo/redo system with overflow management. Perfect for command pattern implementation and history tracking with a fixed-size buffer. When the timeline reaches capacity, oldest items move to an overflow queue that can be restored on undo.Basic Usage
Function Signature
Parameters
Configuration options for the timeline
Maximum number of items in the timeline buffer. When exceeded, oldest items move to overflow.
Returns
Timeline context with undo/redo capabilities
Register a new item, removing oldest if at capacity
Remove the last registered item and store it for redo. Restores from overflow if available.
Restore the last undone item
Current number of items in the timeline
Get all items in the timeline
Remove all items from timeline and overflow
Overflow Management
When the timeline exceeds its size limit, the oldest item moves to an overflow queue:Undo/Redo Behavior
Basic Undo/Redo
Redo Stack Clearing
Registering a new action clears the redo stack:Multiple Undos with Overflow
Command Pattern Example
Context Pattern
Use dependency injection for global timeline access:TypeScript
Custom Ticket Types
Related
- createRegistry - Base registry primitive
- createQueue - Time-based queue with timeouts