I've often wondered why we aren't using inheritance to customize Loaders. I'd be interested in the rationale.
On Sun, Aug 3, 2014 at 2:19 PM, John Barton <johnjbar...@google.com> wrote: > Since I guess not too many developers work with ES6 and the Loader object, > here is some feedback: the Loader callback design does not play well with > ES6 classes. > > The Loader takes 'options', an object with function properties like > normalize, locate, and fetch. If you pass a literal object with function > properties, it works fine. > > If you pass an instance of a class, then you discover that the Loader > calls these functions with 'this' bound to the Loader, not the 'options' > object. > > There isn't a simple way around this as far as I know. The options > functions don't have access to the options object, only module-state and > global. So you're stuck with the awkward: > var loader = new Loader({ > normalize: options.normalize.bind(options), > locate: options.locate.bind(locate), > etc, > }; > I guess you can give up on ES6 inheritance and create the hook instances > by old-school JS, but that is even more annoying. Or maybe there is > something else I've not thought of? > > jjb > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss