Skip to content

Instantly share code, notes, and snippets.

@kazagkazag
Created July 8, 2016 10:17
Show Gist options
  • Select an option

  • Save kazagkazag/93762f1831ad3cc3410170f971c44e80 to your computer and use it in GitHub Desktop.

Select an option

Save kazagkazag/93762f1831ad3cc3410170f971c44e80 to your computer and use it in GitHub Desktop.
// action types
// import types from 'actionTypes.js'
function accounts(state = [], action) {
switch(action.type) {
case types.ADD_ACCOUNT:
return [
...state,
{
id: getNewId(), //fake method that returns new ID
title: action.title,
createdBy: action.createdBy
}
];
case types.DELETE_ACCOUNT:
return deleteAccountByID(action.id); //fake method that returns new array of accounts without specified one
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment