Re: CfC: Battery Status Event FPWD

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 Wednesday, 20 April 2011 20:08:01 UTC