O'Reilly logo

PhoneGap 3.x Mobile Application Development HOTSHOT by Kerri Shotts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Covering Promises and Q.js

As we said before, there's simply got to be a better way to deal with the callback hell that the File API has caused us to suffer. There is, but it takes a little bit of work to get there. For very simple operations, it might not always be worth it, but when you need to chain many operations together, having Promises really pays off.

Getting on with it

You've seen a glimpse of what callback hell looks like. It can get far, far worse. If you'll pardon the pun, Promises promise to alleviate the headache.

For the low-down on this, you might want to take a look at the Promises/A+ specification at http://promises-aplus.github.io/promises-spec/. Note that it doesn't provide any code; the specification leaves it up to other libraries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required