Created
September 15, 2011 21:41
-
-
Save nodesocket/1220563 to your computer and use it in GitHub Desktop.
How To Refactor This, Without Using SetTimeout
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
child.on("start", function(forever) { | |
//A bit of a hack, but we delay before calling the callback because we want to see if error or exit events are fired. | |
setTimeout(function() { | |
typeof this.callback === "function" ? this.callback.call() : null; | |
}.bind({ callback: this.callback }), 500); | |
}.bind({ callback: callback })); | |
child.on("exit", function(forever) { | |
typeof this.callback === "function" ? this.callback.call() : null; | |
}.bind({ callback: callback })); | |
child.on("error", function(err) { | |
typeof this.callback === "function" ? this.callback.call() : null; | |
}.bind({ callback: callback })); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment