Re: On Battery API

>
> 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.

Doug

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