reduce method

The method that returns the new state.

Implementation

@override
TracingState reduce() {
  final initialEvents = events.map((e) => InputEvent.fromJson(e)).toList();
  final runningActions = <int, InputEvent>{};
  final historicalActions = <String, ActionInfo>{};
  _addActionsToMap(
    events: initialEvents,
    runningActions: runningActions,
    historicalActions: historicalActions,
  );
  return state.copyWith(
    events: initialEvents,
    runningActions: runningActions,
    historicalActions: historicalActions,
    hasTracing: true,
    hasFinishedEvents:
        initialEvents.any((e) => e.type == InputEventType.actionFinished),
  );
}