Skip to content

Instantly share code, notes, and snippets.

@marianocodes
Last active August 10, 2018 04:23
Show Gist options
  • Save marianocodes/94711c011aa54021456ded91518e279d to your computer and use it in GitHub Desktop.
Save marianocodes/94711c011aa54021456ded91518e279d to your computer and use it in GitHub Desktop.
NgRx entity
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