Asynchronous Programming in ES6 Using Generators and Promises

by bill-s, 2015-05-16T09:10:23.000Z

Asynchronous programming has started gaining a lot of attention over the past couple of years. In JavaScript-oriented  applications, there are a number of cases (viz., making an AJAX call or executing a piece of logic after certain time) where we need to deal with asynchronous logic. Some of the JavaScript APIs that were added to browsers as part of HTML5 (viz., IndexedDb, Geo locations and Web sockets) are asynchronous. Despite of such heavy usage of asynchrony, JavaScript as a language doesn’t support it well. Callbacks are the only way one can handle asynchronous APIs in JavaScript; but the approach fails to scale. For example, when you have to deal with more than 3 levels of nested callbacks, the code starts forming a nice looking tree that is hard to read and understand.

Read More