const featureReducer = createReducer(
        initialState,
        on(featureActions.action, state => ({ ...state, prop: updatedValue })),
      );
      export function reducer(state: State | undefined, action: Action) {
        return featureReducer(state, action);
      }

      Typescript language logoAngular NgRx Reducer

      Angular TypeScript Recipes

      The code creates a reducer function that takes two parameters: the initial state and an action. The reducer function will use the on() reducer function to handle the action. This on() function will take the action object and the current state and will return a new state. The new state will have the updatedValue property set to the value of the action object.

      Shortcut: angular.ngrx.reducer

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.