Skip to content

Instantly share code, notes, and snippets.

@solomonhawk
Last active August 29, 2015 14:18
Show Gist options
  • Save solomonhawk/fde18a89b9d9ad1db25c to your computer and use it in GitHub Desktop.
Save solomonhawk/fde18a89b9d9ad1db25c to your computer and use it in GitHub Desktop.
let validActions = {
[GameConstants.GAME_CREATE]: null,
[GameConstants.GAME_JOIN]: null,
[GameConstants.GAME_EXIT]: null,
[GameConstants.USER_JOINED]: null,
[GameConstants.USER_LEFT]: null
}
GameDispatcher.register( ({actionType, data}) => {
if (actionType in validActions) {
update(data)
GameStore.emitChange()
}
})
// OR
let validActions = [
GameConstants.GAME_CREATE,
GameConstants.GAME_JOIN,
GameConstants.GAME_EXIT,
GameConstants.USER_JOINED,
GameConstants.USER_LEFT
]
GameDispatcher.register( ({actionType, data}) => {
if (validActions.contains(actionType)) {
update(data)
GameStore.emitChange()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment