Skip to content

Instantly share code, notes, and snippets.

@FrankV01
Last active July 6, 2017 19:23
Show Gist options
  • Save FrankV01/8430a87f0f96b0b1ca0ba04e7fe71d41 to your computer and use it in GitHub Desktop.
Save FrankV01/8430a87f0f96b0b1ca0ba04e7fe71d41 to your computer and use it in GitHub Desktop.
Starting point for promise for article on http://theopensourceu.org/concepts-to-implementations-promise/
// require statements omitted for readability and brevity.
function processData( startingData, cbResult ) {
//
// Do something with startingData and ultimatly set result to finalizedResult.
// ...
var finalizedResult = startingData;
cbResult(finalizedResult);
}
function parentMethod() {
fs.readFile('/my/made/up/file.txt', function callback1(err, data) {
if(err) throw err;
processData( data, function callback2(results) {
sendResultToServer(result, function callback3(response) {
executionOrderGetsConfusing(response);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment