@reduxjs/toolkit#createReducer JavaScript Examples

The following examples show how to use @reduxjs/toolkit#createReducer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mapEntity.js    From Healthyhood with MIT License 6 votes vote down vote up
dataReducer = createReducer(initialState, {
  [DATA_REQUEST]: dataRequestCase,
  [DATA_REQUEST_FAILED]: dataRequestFailedCase,
  [UPDATE_USER_LOCATION]: updateUserLocationCase,
  [YELP_DATA_RECEIVED]: yelpDataReceivedCase,
  [WALK_DATA_RECEIVED]: walkDataReceivedCase,
  [IQAIR_DATA_RECEIVED]: iqAirDataReceivedCase,
  [HEALTH_SCORE_RECEIVED]: healthScoreReceivedCase,
  [TOGGLE_INITIAL_LOAD]: toggleInitialLoadCase,
})
Example #2
Source File: userEntity.js    From Healthyhood with MIT License 6 votes vote down vote up
usersReducer = createReducer(initialState, {
  [USERS_REQUEST]: usersRequestCase,
  [USERS_REQUEST_FAILED]: usersRequestFailedCase,
  [RECEIVED_USER]: receivedUserCase,
  [SET_IS_LOGGED_IN]: setIsLoggedInCase,
  [SET_USERNAME]: setUsernameCase,
  [SET_EMAIL]: setEmailCase,
  [SET_PASSWORD]: setPasswordCase,
  [UPDATE_USER]: updateUserCase,
})
Example #3
Source File: ui.js    From social with The Unlicense 6 votes vote down vote up
uiReducer = createReducer(initialState, (builder) => {
  builder
    .addMatcher(
      (action) => action.type.endsWith(`/${SET_ERRORS}`),
      (state, action) => { state.errors[action.key] = action.errors || true; },
    )
    .addMatcher(
      (action) => action.type.endsWith(`/${SET_LOADING}`),
      (state, action) => {
        state.loading[action.key] = true;
        delete state.errors[action.key];
      },
    )
    .addMatcher(
      (action) => action.type.endsWith(`/${SET_TOAST}`),
      (state, action) => { state.toast = action.payload; },
    )
    .addMatcher(
      (action) => action.type.endsWith(`/${UNSET_ERRORS}`),
      (state, action) => { delete state.errors[action.key]; },
    )
    .addMatcher(
      (action) => action.type.endsWith(`/${UNSET_LOADING}`),
      (state, action) => {
        state.loading[action.key] = false;
      },
    )
    .addMatcher(
      (action) => action.type.endsWith(`/${UNSET_TOAST}`),
      (state) => { state.toast = initialState.toast; },
    );
})
Example #4
Source File: apollo.js    From apollo-epoch with MIT License 6 votes vote down vote up
apolloReducer = createReducer(initialState, {
  [PORT_INITIALIZED]: initializePortCase,
  [POST_BACKGROUND_MESSAGE]: callBackgroundCase,
  [STARTING_UP]: startingUpCase,
  [NO_APOLLO]: noApolloCase,
  [FETCH_APOLLO]: fetchApolloCase,
  [RECEIVED_MANUAL_FETCH]: receivedManualFetchCase,
  [RECEIVED_APOLLO]: receivedApolloCase,
  [INITIALIZED_CACHE_CHECK]: initializedCacheCase,
  [SET_ACTIVE_QUERY]: setActiveQueryCase,
})