Last active
August 29, 2015 14:02
-
-
Save tristanls/3bfde5a2477332b18568 to your computer and use it in GitHub Desktop.
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
var dostuffEmitter = new EventEmitter(); | |
dostuffEmitter.on('task1', function (callback) { | |
if (error) { | |
dostuffEmitter.emit('error', error); | |
return; | |
} | |
dostuffEmitter.emit('task2', x, callback); | |
}); | |
dostuffEmitter.on('task2', function (x, callback) { | |
if (error) { | |
dostuffEmitter.emit('error', error); | |
return; | |
} | |
dostuffEmitter.emit('task3', y, callback); | |
}); | |
dostuffEmitter.on('task3', function (y, callback) { | |
if (error) { | |
dostuffEmitter.emit('error', error); | |
return; | |
} | |
dostuffEmitter.emit('finish', z, callback); | |
}); | |
dostuffEmitter.on('finish', function (z, callback) { | |
if (z < 0) { | |
callback(0); | |
} else { | |
callback(z); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment