On Fri, Sep 26, 2014 at 3:02 PM, [email protected] <[email protected]> wrote: > ```js > function Ctor() { > Ctor.events.forEach( event => window.addEventListener(event, > this['handle_' + event]) ); > } > > Ctor.events = ['a', 'b', 'c']; > > Ctor.prototype.handle_a = function() {}; > Ctor.prototype.handle_b = function() {}; > Ctor.prototype.handle_c = function() {}; > ```
There's still a risk of collisions given that you could be listening to "click" events from two different elements for example. But I agree that it reduces the risk significantly. If this is what people prefer, it's definitely something that we could implement. It gets a little messy in the specific case that we're talking about in this thread, i.e. in settings change observers. Settings names almost always have '.'s in them, which means that the function would be called something like "handle_wallpaper.image_change". But I'm happy to give it a try if people generally think this is a good design. / Jonas _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
