debug method

Reducer<State, Action, Environment> debug()

Wraps this reducer to print each action, previous state, and new state to the console. Useful during development for tracing state changes.

Implementation

Reducer<State, Action, Environment> debug() {
  return Reducer<State, Action, Environment>(
    reduce: (state, action, environment) {
      final (state: newState, effect: effect) = reduce(state, action, environment);
      print('Action: $action');
      print('State: $state');
      print('New State: $newState');
      return (state: newState, effect: effect);
    },
  );
}