W3C home > Mailing lists > Public > public-device-apis@w3.org > April 2014

Battery Status API asynchronous amendment

From: Tim Volodine <timvolodine@google.com>
Date: Wed, 30 Apr 2014 13:30:19 +0100
Message-ID: <CAJv4RS3aHq1K+VQOKv-tjXndRRzaUfLuoksh=MgBV33XDoTE3g@mail.gmail.com>
To: public-device-apis@w3.org
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:33:06 UTC