Last active
August 10, 2018 04:23
-
-
Save marianocodes/94711c011aa54021456ded91518e279d to your computer and use it in GitHub Desktop.
NgRx entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function reducer(state: State = initialState, action: ExampleActions): State { | |
switch (action.type) { | |
case ExampleActionTypes.GetCarList: | |
return { ...state, cars: adapterCar.addMany(action.payload, state.cars) }; | |
case ExampleActionTypes.GetPlaceList: | |
const { payload } = action; | |
return { | |
...state, | |
places: adapterPlace.addMany(payload, { ...state.places, total: payload.length }) | |
}; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment