Re: Loader vs ES6 Classes

2014-08-03 Thread Kevin Smith
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  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


Loader vs ES6 Classes

2014-08-03 Thread John Barton
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


Links within document

2014-08-03 Thread Perry Smith
Hi,

I'm new to the list and have a suggestion.  I hope this is the right place.

I started this email and then went surfing a bit more and found Jason Orendorff 
page.  Thank you Jason.

I usually read the PDF version of the document.  It would help me tremendously 
if each term was linked back to where it was defined (as Jason has done in his 
html version).  pdf or html, my belief is that the links help a lot -- even if 
I "know" a particular topic, being able to quickly refer back and forth is a 
great benefit to me.

Thank you,
Perry Smith



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss