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: Tue, 26 Apr 2011 14:57:07 +0200
Message-ID: <BANLkTikuWTONswHH7gKk=+hEifxSYU=47g@mail.gmail.com>
To: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Cc: public-device-apis@w3.org
Forget it, since it's a native event, just need to fire the event!
It seems ok for my use, thanks for that.

/antoine.


On Wed, Apr 20, 2011 at 10:08 PM, Anssi Kostiainen
<anssi.kostiainen@nokia.com> wrote:
> Hi,
>
> On 20.4.2011, at 16.29, ext Antoine Sanchez wrote:
>
>> 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!
>>
>> It's ambiguous "immediately", immediately after what? load? ready?
>
> Adding to what I said above: the way this event type is initiated and dispatched should not be different from the way any other similar event type is handled. We are reusing the existing DOM Event architecture.
>
>> 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?
>
> Could you elaborate what you mean by already attached, e.g. with a couple of lines of code?
>
> -Anssi
Received on Tuesday, 26 April 2011 12:57:55 GMT

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