The TL;DR Of My Promises Journey
I was working with a client a few years ago and we had a problem. We needed to load up a single Backbone model from a collection, but didn’t have a guarantee of the collection being loaded yet. So I created a way to guarantee callbacks firing. What I didn’t realize at the time, was that promises did exactly this. It was shortly after writing that post that someone introduced me to jQuery Deferred objects. I quickly rewrote my callbacks class to be a thin wrapper around deferred, and moved on. A short time later, I found myself working on a contract for Microsoft Patterns & Practices group, building a Windows 8 / WinJS application. It turns out Windows 8 / WinJS apps are full of promises, and you really do have to understand them if you want to build anything with Win8 / WinJS. This was my first in-depth exposure to “real” promises, though I had become familiar with the term by now, and knew that jQuery’s deferred weren’t quite a “promise” (at least, by the standards at the time. maybe that has changed?).
My Promises Screencasts
Having learned quite a bit about promises and spent a significant amount of time using them in various forms, I created a couple of screencasts around promises – one of which is freely available on Youtube and has a blog post over at Telerik. This screencast shows how to clean up nested callbacks with promises. It’s a great introduction to the things that promises let us do, and shows one option for getting out of callback hell / the christmas tree of doom.
The other is a paid screencast on my WatchMeCode screencast series – Episode 13: Promises From The Ground Up.
This screencast takes you roughly through the same journey that I had when I first needed a promise. It shows some very basic, async code (facilitated with
setTimeout in this case) and then walks through a very minimal (incomplete) promise implementation.
The goal is to break down promises in to what they really are – callbacks that are stored for later execution. If you’ve been beating your head against the wall of promises, trying to understand how they really work (even if you’ve used them successfully!), then this screencast is one that you’ll want to pick up. Tearing down the illusion and revealing the person behind the screen is a powerful way to move from the realm of “magic” (that which we don’t understand) to “technology” (that which we do understand).
Post Footer automatically generated by Add Post Footer Plugin for wordpress.