debug method

Reducer<S, E, A> debug({
  1. String? name,
})

Implementation

Reducer<S, E, A> debug({String? name}) {
  return Reducer<S, E, A>((S state, A action) {
    final displayName = name ?? "";
    // ignore: avoid_print
    print("\n${displayName}Reducer received");
    // ignore: avoid_print
    print("  action: $action");
    // ignore: avoid_print
    print("  state: $state");
    // ignore: avoid_print
    print("  state.hashCode: ${state.hashCode}");
    final newReducerTuple = run(state, action);
    // ignore: avoid_print
    print("and computed");
    // ignore: avoid_print
    print("  state: ${newReducerTuple.state}");
    // ignore: avoid_print
    print("  state.hashCode: ${newReducerTuple.state.hashCode}");
    return newReducerTuple;
  });
}