Skip to content

Instantly share code, notes, and snippets.

@rainerhahnekamp
Last active August 12, 2021 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainerhahnekamp/dd1747da0bd4aa81c46ca033f20780ea to your computer and use it in GitHub Desktop.
Save rainerhahnekamp/dd1747da0bd4aa81c46ca033f20780ea to your computer and use it in GitHub Desktop.
export const customerFeatureKey = 'Customer';
export interface State {customers: Customer[]}
export interface CustomerAppState {
[customerFeatureKey]: State;
}
export const initialState: State = {customers: []};
export const customerReducer = createReducer<State>(
initialState,
on(CustomerActions.loaded, (state, { customers }) => ({...state, customers})),
on(CustomerActions.added, (state, { customers }) => ({...state, customers})),
on(CustomerActions.updated, (state, { customers }) => ({...state, customers})),
on(CustomerActions.removed, (state, { customers }) => ({...state, customers}))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment