Last active
July 6, 2017 19:23
-
-
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/
This file contains hidden or 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
// 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