Skip to content

Instantly share code, notes, and snippets.

@grant
Created May 4, 2014 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grant/c0c10840a3efa13973cd to your computer and use it in GitHub Desktop.
Save grant/c0c10840a3efa13973cd to your computer and use it in GitHub Desktop.
javascript callbacks
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