Skip to content

Instantly share code, notes, and snippets.

@seriousManual
Created February 15, 2012 08:42
Show Gist options
  • Save seriousManual/1834492 to your computer and use it in GitHub Desktop.
Save seriousManual/1834492 to your computer and use it in GitHub Desktop.
showing the problem of asynchrounos functions that behave not asynchrounos
function myObject() {
function initialize() {
//do something
someAsynchrounosFunction( function (err, data) {
this.emit( 'init' );
} );
}
initialize();
}
var o = new myObject();
o.on( 'init', function() {
//will never be fired if someAsynchrounosFunction would behave synchron instead of asynchrounos!
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment