The Promised Land: Untangling Async Spaghetti Code

Trevor Burnham (HubSpot)
Pure Languages, Continental 5
Average rating: ***..
(3.78, 18 ratings)

When you want anything done involving I/O in JavaScript, you’re going to have to pony up a callback. When you want several async things done, in order, with proper error-handling, you might write a series of nested callbacks—but therein lies the path to madness. Understanding and refactoring your code becomes exponentially harder with the number of levels of indentation.

Fortunately, there are some simple techniques that can save you from nested callback hell. Among the most exciting of these are Promises.

Promises have been a part of jQuery since 1.5, but they haven’t yet gotten the love they deserve as a simple, elegant alternative to callback arguments. With Promises, you can write smaller callbacks and write more readable, reusable code.

This talk features material from my upcoming book, Async JavaScript.

Photo of Trevor Burnham

Trevor Burnham

HubSpot

Trevor Burnham is the author of the PragProg book CoffeeScript: Accelerated JavaScript Development. When not spreading the good word about CoffeeScript, he develops web apps in Cambridge, MA. Previous speaking engagements include RailsConf and Øredev.

Comments on this page are now closed.

Comments

James Gardner
05/31/2012 12:37pm PDT

Concise introduction and explanation of the concept. I would have liked to of seen some more real world examples/problems and perhaps more of a bias towards jQuery :)

Picture of Jeff Barczewski
Jeff Barczewski
05/31/2012 12:18pm PDT

A little beginner for my taste but Trevor did a good job of explaining a difficult topic for the masses, so I believe it was of benefit for many of those attending.

Sponsors

  • appendTo
  • Enyo
  • Ludei
  • Sencha
  • Appcelerator
  • Twitter
  • Infragistics
  • Code For America
  • DevChix
  • Eclipse Foundation
  • Women Who Code

For information on exhibition and sponsorship opportunities at Fluent conference, contact Gloria Lombardo at (203) 381-9245 or glombardo@oreilly.com.

For information on trade opportunities with O'Reilly conferences contact mediapartners
@oreilly.com

View a complete list of Fluent contacts