Created
May 4, 2014 01:01
-
-
Save grant/c0c10840a3efa13973cd to your computer and use it in GitHub Desktop.
javascript callbacks
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
function test() { | |
//code | |
codeThatListensToEvent(function() { | |
// finish the code | |
}); | |
} | |
function codeThatListensToEvent(cb) { | |
socket.doStuff(); | |
socket.on('someEvent', function () { | |
// call the callback | |
cb(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment