Created
February 15, 2012 08:42
-
-
Save seriousManual/1834492 to your computer and use it in GitHub Desktop.
showing the problem of asynchrounos functions that behave not asynchrounos
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
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