|
7 | 7 | - [Generators (ES6)](#generators-es6)
|
8 | 8 | - [Async Functions (ES7)](#async-functions-es7)
|
9 | 9 |
|
10 |
| -## Callbacks |
| 10 | +## [Callbacks](https://.com/vasanthk/async-javascript/blob/master/1-callback.js) |
11 | 11 | In JavaScript, functions are first-class objects; that is, functions are of the type Object and they can be used in a first-class manner like any other object (String, Array, Number, etc.) since they are in fact objects themselves. They can be “stored in variables, passed as arguments to functions, created within functions, and returned from functions”.
|
12 | 12 |
|
13 | 13 | Because functions are first-class objects, we can pass a function as an argument in another function and later execute that passed-in function or even return it to be executed later. This is the essence of using callback functions in JavaScript.
|
@@ -88,7 +88,7 @@ Here are two solutions to this problem:
|
88 | 88 | * [Callback Hell](http://callbackhell.com/)
|
89 | 89 | * [Avoiding Callback hell in Node.js](http://stackabuse.com/avoiding-callback-hell-in-node-js/)
|
90 | 90 |
|
91 |
| -## Promises |
| 91 | +## [Promises](https://.com/vasanthk/async-javascript/blob/master/2-promises.js) |
92 | 92 | Promises are usually vaguely defined as “a proxy for a value that will eventually become available”. They can be used for both synchronous and asynchronous code flows, although they make asynchronous flows easier to reason about.
|
93 | 93 |
|
94 | 94 | Promises can be chained “arbitrarily”, that is to say - you can save a reference to any point in the promise chain and then tack more promises on top of it. This is one of the fundamental points to understanding promises.
|
@@ -132,7 +132,7 @@ Rejections will also finish the race, and the race promise will be rejected. Thi
|
132 | 132 | * [Promise Patterns & Anti-Patterns](http://www.datchley.name/promise-patterns-anti-patterns/)
|
133 | 133 | * [What’s the deal with jQuery Deferred objects and Promises?](http://www.vasanthk.com/jquery-promises-and-deferred-objects/)
|
134 | 134 |
|
135 |
| -## Generators (ES6) |
| 135 | +## [Generators (ES6)](https://.com/vasanthk/async-javascript/blob/master/3-generators.js) |
136 | 136 | Generators, a new feature of ES6, are functions that can be paused and resumed. This helps with many applications: iterators, asynchronous programming, etc.
|
137 | 137 |
|
138 | 138 | Two important applications of generators are:
|
@@ -200,7 +200,7 @@ The fact that generators-as-observers pause while they wait for input makes them
|
200 | 200 | * [No promises: asynchronous JavaScript with only generators](http://www.2ality.com/2015/03/no-promises.html)
|
201 | 201 | * [ES6 Generators in Depth](https://ponyfoo.com/articles/es6-generators-in-depth)
|
202 | 202 |
|
203 |
| -## Async Functions (ES7) |
| 203 | +## [Async Functions (ES7)](https://.com/vasanthk/async-javascript/blob/master/4-async-await.js) |
204 | 204 | Async functions take the idea of using generators for asynchronous programming and give them their own simple and semantic syntax.
|
205 | 205 |
|
206 | 206 | ### Converting Promises to Async Functions
|
|
0 commit comments