Last active
December 17, 2015 07:09
-
-
Save dalssoft/5571099 to your computer and use it in GitHub Desktop.
Replace socket.io client event for test
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
socket = new Socket() | |
socket.emit 'config', | |
id: 123 | |
socket.on 'message', (message) => | |
receiveMessage message |
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
class EventEmitter | |
events: {} | |
on: (event, callback) -> @events[event] = callback | |
emit: (event, data) -> @events[event](data) if @events[event] | |
class Socket extends EventEmitter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment