nope, you are limiting your object to have only one listener per event, I think that's not quite how reality is. You gonna lose that listeners next time somebody use same name with the same object.
In (?:io|node)js you have EventEmitter that exposes .on, on web even jQuery needs that reference in order to be able to remove only that listener instead of many. Sure you have .once or .one that might help here, but removing a listener can also be performed for other reasons. If there's no way developers will find their own, but it makes arrow function less attractive, at least to my eyes On Fri, Feb 27, 2015 at 6:04 PM, Claus Reinke <[email protected]> wrote: > and yet you haven't removed any anonymous arrow listener. Assign first? >> Mostly nobody will do that, it's just less natural then `obj.on(something, >> ()=>happening)` >> > > personally? Yes, I tend to assign listeners somewhere, at least when I > intend to remove them later. I've even been known to assign them to a > virtual event object, so that I could translate the event names later > (eg, click vs touch). But that is just me. > > One could also hide the assignment in an `on` helper (JQuery does > something similar). > > function on (obj,event,listener) { > obj._events[event]=listener; > return obj.on(event,listener); > } > > Claus > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

