Skip to content

Instantly share code, notes, and snippets.

@takuya-nakayasu
Created March 19, 2019 12:55
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 takuya-nakayasu/41a85fd9c6429b552283e609a8a79c9f to your computer and use it in GitHub Desktop.
Save takuya-nakayasu/41a85fd9c6429b552283e609a8a79c9f to your computer and use it in GitHub Desktop.
カウンターアプリのReducer
import { Action } from '@ngrx/store';
import { ActionTypes } from '../action/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