undo method

  1. @override
bool undo()
override

Implementation

@override
bool undo() {
  if (!canUndo()) {
    return false;
  }

  final previous = _eventCursor.previous;
  if (previous == null) {
    throw StateError('There should have been an previous link');
  }
  final currentEvent = _eventCursor.value.visit(
    just: (e) => e,
    none: () => throw StateError('There should have been an event now'),
  );
  _eventCursor = previous;
  _snapshot = snapshot.rebuild(currentEvent.undoTo);
  return true;
}