Design Patterns · Senior · Question 44 of 75
How do you implement reliable undo in a collaborative editor with several users editing?
- ✓Correct answer: Undo your own operations while accounting for others' (OT/CRDT)
- 2Keep a snapshot of the whole document and roll back to it
- 3Forbid simultaneous editing altogether
Explanation
A global rollback to a snapshot would destroy other people's changes. In collaborative systems, undo is a new inverse operation on the current state that accounts for concurrent edits. Command and Memento work locally, but collaboration needs OT or CRDT models.