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

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 06:46:36 UTC