Re: [battery] Alternative design proposal (was: addEventListener side effects, ordering & boundary crossing ...)

+1 for the reasons Dom mentions.

if there is no battery would it make sense for b to be null?

regards, Frederick

Frederick Hirsch
Nokia



On Sep 9, 2011, at 2:46 AM, ext Dominique Hazael-Massieux wrote:

> Le vendredi 09 septembre 2011 à 09:01 +0300, Anssi Kostiainen a écrit :
>> Here's a summary of discussed alternatives:
>> 
>> var b = new BatteryStatusEventSource();
>> b.onbatterystatus = function () {};
>> 
>> navigator.battery.start();
>> navigator.battery.onbatterystatus = function () {};
>> 
>> var b = navigator.getBattery();
>> b.onbatterystatus = function () {};
>> 
>> Which one is your favorite, and why?
> 
> I think the last one is probably my favorite, but mostly for cosmetic
> reason: it doesn't add a constructor (which for a singleton seems
> awkward), and it doesn't need the start() method (which reads weird: it
> feels like you're starting the battery itself).
> 
> Dom
> 
> 
> 

Received on Friday, 9 September 2011 12:16:32 UTC