Skip to content

Instantly share code, notes, and snippets.

@nodesocket
Created September 15, 2011 21:41
Show Gist options
  • Save nodesocket/1220563 to your computer and use it in GitHub Desktop.
Save nodesocket/1220563 to your computer and use it in GitHub Desktop.
How To Refactor This, Without Using SetTimeout
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