W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2013

Re: Better event listeners

From: Robin Berjon <robin@w3.org>
Date: Thu, 10 Jan 2013 16:19:00 +0100
Message-ID: <50EEDBE4.1020100@w3.org>
To: brandon.wallace@yahoo.com
CC: "www-dom@w3.org" <www-dom@w3.org>
On 10/01/2013 14:38 , brandon.wallace@yahoo.com wrote:
>> I meant that, if an object with methods were returned, the method
>> should be named "off" as opposed to "cancel" or "stop" etc. Agreed
>> that a function instead of an object is more elegant, however.
>
> I believe it has been mentioned that an object leaves the door open
> for future enhancements.  Returning only a function limits your
> options for future enhancements.

Actually, just because it's a function doesn't mean it can't be extended:

var obj = function () { console.log("stop"); };
obj.start = function () { console.log("start"); };
obj();
obj.start();

Whether that's elegant is another question.

-- 
Robin Berjon - http://berjon.com/ - @robinberjon
Received on Thursday, 10 January 2013 15:19:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 10 January 2013 15:19:12 GMT