June 2016
Intermediate to advanced
910 pages
18h 59m
English
The new asynchronous JavaScript APIs are now based on the Promise pattern instead of events and callbacks. And the new versions of the old JavaScript APIs are now based on Promises.
For example, the old version of the Battery status API and the Web Cryptography API were based on event, but the new versions of these APIs are purely implemented using Promises. Let's see an overview of these APIs.
The Battery Status API provides us the battery's current charge level and charging status. Here is a code example of the new Battery Status API:
navigator.getBattery().then(function(value){ console.log("Batter Level: " + (value.level * 100)); }, function(reason){ console.log("Error: " + reason); }); ...Read now
Unlock full access