Skip to content

Instantly share code, notes, and snippets.

@ramonvictor
Last active April 30, 2016 09:55
Show Gist options
  • Save ramonvictor/87d12ce9b59db477fcb6bdbb931b9b86 to your computer and use it in GitHub Desktop.
Save ramonvictor/87d12ce9b59db477fcb6bdbb931b9b86 to your computer and use it in GitHub Desktop.
// Reducer (pure function)
function updatePlayer(player, action) {
switch (action.type) {
case 'PICK_SIDE':
return action.side;
default:
return player || '';
}
}
// Call reducer on Store.update()
Store.prototype.update = function(state, action) {
return {
player: updatePlayer(state.player, action)
// [...other reducers]
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment