Last active
April 30, 2016 09:55
-
-
Save ramonvictor/87d12ce9b59db477fcb6bdbb931b9b86 to your computer and use it in GitHub Desktop.
This file contains 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
// 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