Battery Status API asynchronous amendment

We are proposing a change to the current Battery Status API (
http://www.w3.org/TR/battery-status/) such that it is completely
asynchronous. This will allow for less constrained and more efficient
current and future implementations.

More concretely the proposal is to return the battery object asynchronously
as a promise, e.g.

function onBatterySuccess(battery) {
  console.log(batery.level);
}
function onBatteryFailure(msg) {
  console.log("battery information not available");
}
navigator.getBattery().then(onBatterySuccess, onBatteryFailure);

Mozilla who has the only browser currently shipping the Battery Status API
has indicated that they would be fine with such change. We are currently in
the process of implementing this API in chrome as well.

thanks,
Tim

Received on Wednesday, 30 April 2014 12:34:34 UTC