Permalink
Browse files

Shuffle README content

Move section covering the advantages of Promises over callbacks so that it
follows the first lab.
  • Loading branch information...
matt-brendzel committed Jul 1, 2016
1 parent 01b31ee commit 70266c0adc16e15540c04472e4bc3707422ac987
Showing with 15 additions and 12 deletions.
  1. +15 −12 README.md
@@ -29,25 +29,28 @@ Callback drawbacks:
- Each callback will have to handle it's own errors if necessary.
- In complex programs, it will be hard to tell in what order callbacks fire.

Pros for Promises:
Fortunately, there's a better way: Promises.

- Promises, like callbacks, make asynchronicity explicit.
- Promises, unlike callbacks, clarify the order of execution.
- Promises are easier to read than callbacks.
- Promises can simplify error handling.

## Lab: Research the Promises API
### Lab: Research the Promises API

Take a few minutes to read the following API documentation for the [native
Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
Promises are objects that represent steps in an asynchronous process.
As of 2016, they are natively supported in Node.

Note function signatures and argument types as you read. What kind of object
does a promise take when it is constructed?
Take a few minutes to read the API documentation on [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
Note function signatures and argument types as you read.
What arguments does a promise take when it is constructed?

1. [Promise Syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Syntax)
1. [Promise.prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Methods_2)

## Annotate-Along: Using Promises Instead of Callbacks
### Annotate-Along: Using Promises Instead of Callbacks

Promises offer several advantages over callbacks.

- Promises, like callbacks, make asynchronicity explicit.
- Promises, unlike callbacks, clarify the order of execution.
- Promises are easier to read than callbacks.
- Promises can simplify error handling.

```js
// remember that callback is something you write, in this case to perform some

0 comments on commit 70266c0

Please sign in to comment.