W3C home > Mailing lists > Public > public-device-apis@w3.org > June 2011

Re: On Battery API

From: Doug Turner <doug.turner@gmail.com>
Date: Thu, 16 Jun 2011 08:48:41 -0700
Message-ID: <BANLkTi=-i3dWZZHNY8=3+_T+C2GR0-h0Lw@mail.gmail.com>
To: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Cc: public-device-apis@w3.org
> With my web developer hat on I'd love the idea of being able to rely on the implementations providing me reliable and consistent (with each other) BatteryLow and BatteryCriticallyLow events. That said, I also see that a clever JavaScript hacker could come up with a Battery.js library built on top of the current event that would provide me such functionality (by monitoring the level over time).

You are assuming that battery.js has some time to watch the battery
level change over time.  The OS is the thing that is going to give you
the best signal that the device is "Low" because it is watching the
power curve over a very long period of time.  You could try simulating
this -- but at some point you are going to have code that does:

if battery.level == 10 // cause 10 is my magic number
   then send the low level notification

>> 3) We can factor out |battery.plugged| into a new separate event that
>> can fire when there is a change in state.  People may want just this
>> information and not the |battery.level|.
> Is there an (implementation) cost of getting the level as well at the same time?

Probably nothing significant.

Received on Thursday, 16 June 2011 15:49:10 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:49 UTC