Forked from joepie91/promises-reading-list.md
Created
February 25, 2016 15:48
Revisions
-
joepie91 revised this gist
Nov 9, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,11 @@ Many examples on the internet don't show this, but you should __always__ start a ## Odds and ends Some potentially useful snippets: * [Flattening an array of arrays, when using promises](https://gist.github.com/joepie91/ac1ee270c6a506405d5f) You're unlikely to need any of these things, if you just stick with either Bluebird or ES6 promises: * [How to test whether a Promises implementation handles callbacks correctly](https://gist.github.com/joepie91/48042173a6c9c4065399) * [Why this matters.](https://gist.github.com/joepie91/98576de0fab7badec167) -
joepie91 revised this gist
Nov 9, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -54,5 +54,7 @@ Many examples on the internet don't show this, but you should __always__ start a ## Odds and ends You're unlikely to need any of these things, if you just stick with either Bluebird or ES6 promises. * [How to test whether a Promises implementation handles callbacks correctly](https://gist.github.com/joepie91/48042173a6c9c4065399) * [Why this matters.](https://gist.github.com/joepie91/98576de0fab7badec167) -
joepie91 revised this gist
Nov 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Many examples on the internet don't show this, but you should __always__ start a * [Documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) * [Promise.try using ES6 Promises](https://gist.github.com/joepie91/255250eeea8b94572a03) * [Promise.delay using ES6 Promises](https://gist.github.com/joepie91/583db45f3a30552a7cd2) ## Odds and ends * [How to test whether a Promises implementation handles callbacks correctly](https://gist.github.com/joepie91/48042173a6c9c4065399) -
joepie91 revised this gist
Nov 9, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -50,4 +50,9 @@ Many examples on the internet don't show this, but you should __always__ start a * [Documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) * [Promise.try using ES6 Promises](https://gist.github.com/joepie91/255250eeea8b94572a03) * [Promise.delay using ES6 Promises](https://gist.github.com/joepie91/583db45f3a30552a7cd2) * ## Odds and ends * [How to test whether a Promises implementation handles callbacks correctly](https://gist.github.com/joepie91/48042173a6c9c4065399) * [Why this matters.](https://gist.github.com/joepie91/98576de0fab7badec167) -
joepie91 revised this gist
Oct 29, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o ## Introduction * Start reading [here](http://bluebirdjs.com/docs/why-promises.html), to understand why Promises matter. * If it's not quite clear yet, [some code that uses callbacks, and its equivalent using Bluebird](https://gist.github.com/joepie91/c6aa1ee552dcac821d03). * [A demonstration of how promise chains can be 'flattened'](https://gist.github.com/joepie91/211c8e99fb5a83b76079) @@ -29,7 +29,7 @@ Many examples on the internet don't show this, but you should __always__ start a ## Promisifying * [Promisifying functions and modules that use nodebacks](http://bluebirdjs.com/docs/api/promisification.html) (Node.js callbacks) * [An example of manually promisifying an EventEmitter](https://gist.github.com/joepie91/3610c6e41bc654ccaadf) * [Promisifying `fs.exists`](https://gist.github.com/joepie91/bbf495e044da043de2ba) (which is async, but doesn't follow the nodeback convention) -
joepie91 revised this gist
Oct 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [bluebird-tap-error](https://www.npmjs.com/package/bluebird-tap-error), a module for intercepting and looking at errors, without preventing propagation. Useful if you need to do the actual error handling elsewhere. * [Handling errors in Express, using Promises](http://cryto.net/~joepie91/blog/2015/05/14/using-promises-bluebird-with-express/) Many examples on the internet don't show this, but you should __always__ start a chain of promises with Promise.try, and if it is within a function or callback, you should always __return__ your promises chain. Not doing so, will result in less reliable error handling and various other issues (eg. code executing too soon). ## Promisifying -
joepie91 revised this gist
Sep 20, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [A quick introduction](https://gist.github.com/joepie91/c8d8cc4e6c2b57889446) * [Implementing 'fallback' values](https://gist.github.com/joepie91/f6a56acdae303e90e44a) (ie. defaults for when an asynchronous operation fails) * [bluebird-tap-error](https://www.npmjs.com/package/bluebird-tap-error), a module for intercepting and looking at errors, without preventing propagation. Useful if you need to do the actual error handling elsewhere. * [Handling errors in Express, using Promises](http://cryto.net/~joepie91/blog/2015/05/14/using-promises-bluebird-with-express/) Many examples on the internet don't show this, but you should __always__ start a chain of promises with Promise.try, and __always__ return your promises chain from a function or callback. Not doing so, will result in less reliable error handling and various other issues (eg. code executing too soon). -
joepie91 revised this gist
Sep 18, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [A quick introduction](https://gist.github.com/joepie91/c8d8cc4e6c2b57889446) * [Implementing 'fallback' values](https://gist.github.com/joepie91/f6a56acdae303e90e44a) (ie. defaults for when an asynchronous operation fails) * [bluebird-tap-error](https://www.npmjs.com/package/bluebird-tap-error), a module for intercepting and looking at errors, without preventing propagation. Useful if you need to do the actual error handling elsewhere. Many examples on the internet don't show this, but you should __always__ start a chain of promises with Promise.try, and __always__ return your promises chain from a function or callback. Not doing so, will result in less reliable error handling and various other issues (eg. code executing too soon). -
joepie91 revised this gist
Sep 5, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [A quick introduction](https://gist.github.com/joepie91/c8d8cc4e6c2b57889446) * [Implementing 'fallback' values](https://gist.github.com/joepie91/f6a56acdae303e90e44a) (ie. defaults for when an asynchronous operation fails) Many examples on the internet don't show this, but you should __always__ start a chain of promises with Promise.try, and __always__ return your promises chain from a function or callback. Not doing so, will result in less reliable error handling and various other issues (eg. code executing too soon). ## Promisifying -
joepie91 revised this gist
Aug 30, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,8 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [A quick introduction](https://gist.github.com/joepie91/c8d8cc4e6c2b57889446) * [Implementing 'fallback' values](https://gist.github.com/joepie91/f6a56acdae303e90e44a) (ie. defaults for when an asynchronous operation fails) Many examples on the internet don't show this, but you should __always__ start a chain of promises with Promise.try, and __always__ return your promises chain from a function or callback. Not doing so, will result in less reliable error handling. ## Promisifying * [Promisifying functions and modules that use nodebacks](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification) (Node.js callbacks) -
joepie91 revised this gist
Aug 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o ## Introduction * Start reading [here](https://github.com/petkaantonov/bluebird#what-are-promises-and-why-should-i-use-them), to understand why Promises matter. * If it's not quite clear yet, [some code that uses callbacks, and its equivalent using Bluebird](https://gist.github.com/joepie91/c6aa1ee552dcac821d03). * [A demonstration of how promise chains can be 'flattened'](https://gist.github.com/joepie91/211c8e99fb5a83b76079) -
joepie91 revised this gist
Aug 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Promises reading list This is a list of examples and articles, in roughly the order you should follow them, to show and explain how promises work and why you should use them. I'll probably add more things to this list over time. This list primarily focuses on Bluebird, but the basic functionality should also work in ES6 Promises, and some examples are included on how to replicate Bluebird functionality with ES6 promises. You should still use Bluebird where possible, though - they are faster, less error-prone, and have more utilities. -
joepie91 revised this gist
Aug 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -40,7 +40,7 @@ Bluebird will __not__ work correctly in older browsers. If you need to support o * [Example of retaining scope through nesting](https://gist.github.com/joepie91/7d22af310ef68de4f507) * [Example of 'breaking out' of a chain through nesting](https://gist.github.com/joepie91/c5f99a18975df0bf2f98) * [Example of a nested Promise.map](https://gist.github.com/joepie91/2aafe9e4830e0d0c8171) * An example with increasing complexity, implementing an 'error-tolerant' Promise.map: [part 1](https://gist.github.com/joepie91/045a0238d0751cc7a72b), [part 2](https://gist.github.com/joepie91/11e36819dcca49f54348), [part 3](https://gist.github.com/joepie91/9593551b41f568a75b08) ## ES6 Promises -
joepie91 created this gist
Aug 30, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ # Promises reading list This is a list of examples and articles, in roughly the order you should follow them, to show and explain how promises work and why you should use them. This list primarily focuses on Bluebird, but the basic functionality should also work in ES6 Promises, and some examples are included on how to replicate Bluebird functionality with ES6 promises. You should still use Bluebird where possible, though - they are faster, less error-prone, and have more utilities. I'm available for [tutoring and code review](http://cryto.net/~joepie91/code-review.html) :) You may reuse all gists for any purpose under the [WTFPL](http://www.wtfpl.net/txt/copying/) / [CC0](https://creativecommons.org/publicdomain/zero/1.0/) (whichever you prefer). ## Compatibility Bluebird will __not__ work correctly in older browsers. If you need to support older browsers, and you're using Webpack or Browserify, you should use the [`es6-promise`](https://www.npmjs.com/package/es6-promise) module instead, and reimplement behaviour where necessary. ## Introduction * Start reading [here](https://github.com/petkaantonov/bluebird#what-are-promises-and-why-should-i-use-them), to understand why Promises matter: * If it's not quite clear yet, [some code that uses callbacks, and its equivalent using Bluebird](https://gist.github.com/joepie91/c6aa1ee552dcac821d03). * [A demonstration of how promise chains can be 'flattened'](https://gist.github.com/joepie91/211c8e99fb5a83b76079) ## Error handling * [A quick introduction](https://gist.github.com/joepie91/c8d8cc4e6c2b57889446) * [Implementing 'fallback' values](https://gist.github.com/joepie91/f6a56acdae303e90e44a) (ie. defaults for when an asynchronous operation fails) ## Promisifying * [Promisifying functions and modules that use nodebacks](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification) (Node.js callbacks) * [An example of manually promisifying an EventEmitter](https://gist.github.com/joepie91/3610c6e41bc654ccaadf) * [Promisifying `fs.exists`](https://gist.github.com/joepie91/bbf495e044da043de2ba) (which is async, but doesn't follow the nodeback convention) ## Functional (map, filter, reduce) * [Functional programming in Javascript: map, filter and reduce](http://cryto.net/~joepie91/blog/2015/05/04/functional-programming-in-javascript-map-filter-reduce/) (an introduction, not Bluebird-specific, but important to understand) * [(Synchronous) examples of map, filter, and reduce in Bluebird](https://gist.github.com/joepie91/34742045a40f7c48430e) * [Example of using map for retrieving a (remote) list of URLs with bhttp](https://gist.github.com/joepie91/4c125c45ee6c5ea0375f) ## Nesting * [Example of retaining scope through nesting](https://gist.github.com/joepie91/7d22af310ef68de4f507) * [Example of 'breaking out' of a chain through nesting](https://gist.github.com/joepie91/c5f99a18975df0bf2f98) * [Example of a nested Promise.map](https://gist.github.com/joepie91/2aafe9e4830e0d0c8171) * An example with increasing complexity, implementing 'error-tolerant' Promise.map: [part 1](https://gist.github.com/joepie91/045a0238d0751cc7a72b), [part 2](https://gist.github.com/joepie91/11e36819dcca49f54348), [part 3](https://gist.github.com/joepie91/9593551b41f568a75b08) ## ES6 Promises * [Documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) * [Promise.try using ES6 Promises](https://gist.github.com/joepie91/255250eeea8b94572a03) * [Promise.delay using ES6 Promises](https://gist.github.com/joepie91/583db45f3a30552a7cd2)