Skip to content

Instantly share code, notes, and snippets.

@sminutoli
Created September 12, 2017 18:12
Show Gist options
  • Save sminutoli/0d913fae8a5128c77ef268babe051f73 to your computer and use it in GitHub Desktop.
Save sminutoli/0d913fae8a5128c77ef268babe051f73 to your computer and use it in GitHub Desktop.
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