Skip to content

Instantly share code, notes, and snippets.

@darrenmothersele
Created December 20, 2018 14:12
Show Gist options
  • Save darrenmothersele/350757068a891fdb5aa1ad1f9b585bf9 to your computer and use it in GitHub Desktop.
Save darrenmothersele/350757068a891fdb5aa1ad1f9b585bf9 to your computer and use it in GitHub Desktop.
import { Action } from '@ngrx/store';
import { ActionTypes } from './counter.actions';
export const initialState = 0;
export function counterReducer(state = initialState, action: Action) {
switch (action.type) {
case ActionTypes.Increment:
return state + 1;
case ActionTypes.Decrement:
return state - 1;
case ActionTypes.Reset:
return 0;
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment