reduce method

  1. @override
CoreState reduce()

The reduce method is the action reducer. It may read the action state, the store state, and then return a new state (or null if no state change is necessary).

It may be synchronous (returning AppState or null) or async (returning Future<AppState> or Future<null>).

The StoreConnectors may rebuild only if the reduce method returns a state which is both not null and different from the previous one (comparing by identical, not equals).

Implementation

@override
CoreState reduce() {
  final UserRegistrationState? newState =
      state.userRegistrationState?.copyWith.call(
    userType: userType ?? state.userRegistrationState!.userType,
    userRegistrationMutation: userRegistrationMutation ??
        state.userRegistrationState!.userRegistrationMutation,
    userResponse: userResponse ?? state.userRegistrationState!.userResponse,
    primaryRouteName:
        primaryRouteName ?? state.userRegistrationState!.primaryRouteName,
    secondaryRouteName:
        secondaryRouteName ?? state.userRegistrationState!.secondaryRouteName,
  );

  return state.copyWith(userRegistrationState: newState);
}