|Google APIs Adopt Promises
|Written by Ian Elliot
|Friday, 03 October 2014
The Promise is an object returned by the API call which holds the state of the call - pending, fulfilled or rejected. You can use the Promise object's methods, usually then, to specify what should happen when the state changes to fulfilled or rejected.
The original version of the library was based on callbacks, but a measure of backward compatibility has been maintained in the transisiton to Promises. The methods only return a Promise object if a callback function isn't supplied.
The key advantage of Promises is that requests can be chained in a fluent style and this makes the code more readable because it is closer to the flow of control that corresponds to the asynchronous process if each call was blocking.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Friday, 03 October 2014 )