Created
August 13, 2011 12:07
-
-
Save bdickason/1143780 to your computer and use it in GitHub Desktop.
Event design - client listens directly to object
This file contains hidden or 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
class enemy extends EventEmitter | |
load: -> | |
emit 'load' | |
move: (location) -> | |
# moves an enemy across the game | |
emit 'move', location | |
class world extends EventEmitter | |
enemy.on 'load' | |
# process loading | |
emit 'loaded', enemy | |
enemy.move [3, 2] | |
class client extends EventEmitter | |
world.on 'loaded', object | |
# load object data | |
object.on 'move' | |
# show enemy moving to the client | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment