Skip to content

Instantly share code, notes, and snippets.

@nsacerdote
Created October 2, 2020 12:45
Show Gist options
  • Save nsacerdote/e6ff2586941bf605ca9ad835476c9a20 to your computer and use it in GitHub Desktop.
Save nsacerdote/e6ff2586941bf605ca9ad835476c9a20 to your computer and use it in GitHub Desktop.
function doSomething() {
const results = {};
return performStep1()
.then(result1 => (results.one = result1))
.then(() => performStep2(results.one))
.then(result2 => (results.two = result2))
.then(() => performStep3(results.two))
.then(result3 => performFinalStep(results.one, result3))
.then(finalResult => ({
result2: results.two,
finalResult,
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment