My personal introduction to the promise pattern came a couple years ago when I started looking into Windows 8 app development with WinJS, which includes an intuitive implementation of promises that conforms to the Promises/A standard. With my positive introduction to this pattern–which is much more intuitive manner of handling async responses by chaining promise objects and passing your callbacks into the promises then method, rather than nesting your callbacks–I then started looking into Deferreds in jQuery. In all honesty, though, I find I rarely use them as I find the jQuery implementation to be not at all intuitive. So it is with this background, I dove into Sarieddine’s work.
There is a lot to like in this book. He does a good job explaining how the Promises/A+ pattern works, how it differs from the Promises/A standard, where it is in terms of standardization with ECMAScript 6 and current browser support, what some of the libraries are out these that will polyfill support in the interim, and how error handling is done. Additionally, he steps us a through an implementation of a basic Promises/A+ compliant promises object model. I often times found myself saying I wish it would explain such-and-such, and within a few pages it would. One such instance was I wished he would show us how to convert a jQuery Deferred into a promise, and then he did so with the Q and Promise libraries (p. 26).
The book also tends not to use practical examples, but rather the examples tend to be functions that return messages of the alert(“Hello there”) variety. One in-depth practical example, maybe creating a mash-up calling into an API would, perhaps, help drill home how useful promises are, rather than being left simply with theoretical promise. This likely would make a better chapter than the chapter devoted to WinJS.
And, while I hate to be that proverbial guy, the editing job on the book needs some serious work. Throughout it appears auto-capitalization is used on function names if they are the first word in a sentence. With promises, where the methods have name like “then”, this can make for a confusing read as on first read you think it’s the word “Then,” when it’s actually the method “then.”
But having said that, there is a lot of useful content in here, and you will come out of this with a solid understanding of promises and the current state of them. Worth the read, but debatable if it’s worth the price.
Amazon Rating: 4 out of 5 stars