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

Re: CfC: Battery Status Event FPWD

From: Antoine Sanchez <ckkoshi@gmail.com>
Date: Wed, 20 Apr 2011 15:29:39 +0200
Message-ID: <BANLkTi=3U6xzAig7=RA1a0HY-1RP6jPGdg@mail.gmail.com>
To: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Cc: public-device-apis@w3.org
Thanks for clarification!

On Tue, Apr 19, 2011 at 5:12 PM, Anssi Kostiainen
<anssi.kostiainen@nokia.com> wrote:
> Hi Antoine,
>
> I believe your use case is related to real events, not synthetic ones? In that case, to get the battery status as soon as possible after the 'load' event has been fired you should do it as described in the Examples:
>
>  http://dev.w3.org/2009/dap/system-info/battery-status.html#examples
>
> Currently the spec says: "The User Agent must dispatch a BatteryStatusEvent event immediately". That's ambiguous and an item to be fleshed out. I've envisioned that "immediate" would mean "queue as a post-load task" but the details are still to be defined. The HTML5 spec goes into detail about the process (http://dev.w3.org/html5/spec/the-end.html), but most importantly, the event would get dispatched only after e.g. the 'DOMContentLoaded' and 'load' events have been fired. So technically, it would never really fire "on load".
>
> You would only want to call the initBatteryStatusEvent() if you wish to create a synthesized event. If that's the case, you'll first have to create the event via document.createEvent(), then prepare the event by invoking event.initBatteryStatusEvent(), and finally dispatch it via window.dispatchEvent() (or o.dispatchEvent() if you're synthesizing a battery status event for an auxiliary device exposed on the o object).
>
>> also, it would be easier that level is a %, to avoid problem like each
>> navigator use is own level (5, 10, 100).
>
>
> Actually, the level is meant to be a %. It seems we'll have to make that clearer. Thanks for the remark!
>
> -Anssi


It's ambiguous "immediately", immediately after what? load? ready?
You're right, the synthesized event is the easier way to get the battery status.
But why not make this event already attached? like load, click, keydown?

/antoine.
Received on Wednesday, 20 April 2011 13:30:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:20 GMT