Skip to content

Instantly share code, notes, and snippets.

@dherges
Last active May 11, 2018 13:15
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 dherges/8fd262232a2136e5d441bcb05a1efef0 to your computer and use it in GitHub Desktop.
Save dherges/8fd262232a2136e5d441bcb05a1efef0 to your computer and use it in GitHub Desktop.
Reducer
import { Todo } from './model';
export interface State {
[id: string]: Todo
}
export function reducer(state: State, action): State {
switch (action.type) {
case Types.ADD_TODO:
const id = action.payload.id;
return {
...state,
[id]: action.payload
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment