Angular NgRx Reducer



    Jose Romero

    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.

    Library: angular

    Shortcut: angular.ngrx.reducer

    const featureReducer = createReducer(
      on(featureActions.action, state => ({ ...state, prop: updatedValue })),
    export function reducer(state: State | undefined, action: Action) {
      return featureReducer(state, action);
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.