Created
September 12, 2017 18:12
-
-
Save sminutoli/0d913fae8a5128c77ef268babe051f73 to your computer and use it in GitHub Desktop.
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
import { Counter, createCounter, increment, decrement } from '../../entities/Counter'; | |
import { CounterAction } from './actions'; | |
import { CounterActionTypes } from './types'; | |
import { identity } from './lodash-identity'; | |
export type CounterState = Counter; | |
const initialState: CounterState = createCounter(); | |
function counterReducer (state: CounterState = initialState, action: CounterAction): CounterState { | |
return (this[action.type] || identity)(state); | |
} | |
counterReducer[CounterActionTypes.INCREMENT] = increment; | |
counterReducer[CounterActionTypes.DECREMENT] = decrement; | |
export counterReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment