JavaScript Promises – Gotchas and Anti Patterns

tl;dr

  • Flatten the Promise chain whenever possible
  • Straighten multiple nested promises with q.all() and q.spread()
  • Don’t break the Promise chain. Make sure that the last promise is returned to the caller.
  • Don’t overuse deferreds. Use them to promisify callback functions. In case a function returns a promise, it’s just better to form a chain with that same promise.

The long version

Continue reading

Advertisements

Ship It Day

Last week, EE India conducted its first ever Hackathon.

Titled Ship It Day, this code-fest challenged its participants to create, test and ship fully functional software within 24 hours…

Seems challenging?  Interesting??   Fun???…  Well it was all that… and how!!! Continue reading