Author: Daniel Parker
Are you confused by promises? Perhaps 94 pages is all it takes to be unconfused.
The first thing to say is that, while some polyfix libraries do get a mention, this book is mostly about the Promises standard as implemented in ES6. Given that there are many cases where you have to support browsers that are not up-to-date this is still a limitation on how easily you can make use of Promises.
From here Chapter 2 introduces basic Promises. To be honest this isn't very basic. After a very small simple example, things progress very quickly and we are faced with more advanced uses - chaining, multiple consumers and error propagation. This isn't unreasonable as, if you are going to use Promises to wrap the use of a single callback, there isn't too much advantage. To see why Promises is a good idea you really do have to look at more complicated use cases. These are all clearly, but briefly, described. My only reservation is that it might be too brief if you are struggling to see the advantages of Promises. For example, a key advantage is the way errors propagate and this is treated here in just two pages - there is a complete chapter on the topic later, however.
Chapter 3 is titled "Working with Standard Promises", but it is really a sort of cookbook of situations in which you can use Promises. It covers dealing with a conditional and a loop and other common programming structures.
Chapter 4 looks a using libraries and frameworks, but really it only looks at the Bluebird Promise Library. It does mention jQuery and the well-known problems with its implementation of Promises. However, it doesn't really explain what is wrong and doesn't mention that the problem is put right in jQuery 3.0
Chapter 5 is entirely dedicated to explaining error handling. Much of the message is the idea that functions that return Promises shouldn't throw errors, they should reject the Promise. This is perhaps the most important chapter in the book - read it carefully.
And this brings me to a small potential problem with the whole book, or rather its subject matter. As a concept, Promises is difficult for the average programmer to understand and the fault lies with the very idea. In practice, Promises are sophisticated and using them properly requires the level of maturity and knowledge that Danail Parker sets out to deliver. In the main he succeeds. If you want to know how Promises work and how to use them then read this book very carefully, think hard about what it says and them think really hard when you start to use Promises in any sort of creative way. Or you could just wait for async and await which you will understand immediately and write good code without even trying. A good book but not a good technology.
|Last Updated ( Tuesday, 15 March 2016 )|