Part of Chapter 1 demonstrates how complicated chained callbacks can become and how much easier they are to read when presented as promises instead. The chapter concludes with an interesting summary: "Promises are a pattern that allows for a standardized approach in asynchronous programming" and enables "developers to write asynchronous code that is more readable and maintainable."Chapter 2: The Promise API and Its Compatibility
The second chapter's discussion rises back to a higher level of discussion on "browser support and compatibility" for promises. This includes a reproduction (in color in electronic edition) of the Promises portion of the "ECMAScript 6 compatibility table" provided by kangax. The author introduces Remy Sharp's concept of a polyfill ("piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively") and then references a particular polyfill for web browsers that don't support promises natively.
Chapter 2 moves onto coverage of "libraries with promise-like features" and provides descriptions of libraries that implement "the promises concept" (though not necessarily ECMAScript 6 or Promises/A+ compliant). The briefly described libraries are kriskowal/q, tildeio/rsvp.js, cujojs/when.js, the then collection, and jQuery.Deferred().
Chapter 3: Chaining of Promises
Chapter 4: Error Handling
Chapter 5: Promises in WinJS
Unsurprisingly, the fifth chapter emphasizes the WinJS.Promise object. The three main components of a WinJS.Promise object (Constructors, single Event, and Methods) are discussed. The discussion on WinJS.Promise's methods contrasts the then and done methods. This section also explains that WinJS is compliant with Promises/A, but not tested for compliance with Promises/A+ and explains practical ramifications of this.
Chapter 6: Putting It All Together – Promises in Action
Once the simple promises implementation is built, the chapter moves onto using that implementation in examples. The chapter's summary also serves as a summary of the entire book.
- Some of the text in the book is a bit choppy and some of it I'm not even sure conveys what was originally intended. Here is an example: "Callbacks are lightweight since we need to add extra libraries."
- The code listings are black font on white background with proper indenting but without line numbers or color syntax highlighting.
- Because book reviews are opinionated by nature, it can be useful to read several different reviews for different opinions. Other reviews can be found (or likely soon will be found) at the following sources: