nullable method

Reducer<State?, Action, Environment> nullable()

Wraps this reducer to handle nullable state.

If the state is null, returns null state with no effects. Otherwise, delegates to the original reducer.

Implementation

Reducer<State?, Action, Environment> nullable() {
  return Reducer<State?, Action, Environment>(
    reduce: (state, action, environment) {
      if (state == null) {
        return (state: null, effect: Effect.none());
      }
      return reduce(state, action, environment);
    },
  );
}