codepath / nodejs_guides

Comprehensive open-source Node.js guides
76 stars 19 forks source link

Control-flow #3

Closed CrabDude closed 9 years ago

CrabDude commented 9 years ago
  1. Define callback & show simple example
  2. Explain the Callback Contract by providing examples (don't need to cover every point necessarily) and explanations for why they're important
  3. Explain the benefits of promises over callbacks:
    • adopted into language
    • automatic error catching
    • hold value (.then can be attached any time)
    • .chainable
    • A verifiable spec that has all the benefits of the callback contract
  4. Include a link to a more elaborate explanation
  5. Cover the fundamentals of the promise API (.then(success, failure), .done(), .all(), .catch()) with very very simple commented examples
  6. Describe the 3 common control-flow situations & provide examples:
    • parallel
    • series
    • branching (i.e., nesting a promise so it can have it's own independent flow)
  7. Discuss that we'll be using bluebird for performance reasons and the need for the bluebird-nodeify package
  8. Show async/await example of the 3 common control-flow situations
  9. Show how async functions can be passed values, return values, return a promise and auto-catch (see here for reference)
  10. Mention how bluebird.coroutine is mostly equivalent and can be used without babel (--harmony)

What success looks like: Succinctness and clarity. Less is more. Reference Wikis: Authentication & Authorization, Setup

Open separate issues for required links to community sources if you're having trouble finding any.

Please assign to yourself before working on this. /cc @NinjaSudo @philster @azoff @DiyahM