On Wed, Jun 3, 2015 at 1:27 AM, Benjamin Gruenaum <benjami...@gmail.com> wrote:
> Am I missing something obvious in `super((resolve, reject) => this)` ? > > First of all, it makes perfect sense for `this` not work work before super > has been called - and it has not been called yet. > Rather than starting off by claiming the restriction on "this" before "super()" makes perfect sense, let's be honest that lots of normal developers will be tripped up by this restriction. "this" is used a reference throughout class code: it makes "perfect sense" to use it in a constructor. Passing extended-class-specific values to super() is exactly what super() does. Thus using "this" in a constructor before calling super() is entirely natural in light of other experience with the language. Our inability to support "this" before super() is unfortunate, so let's sympathize and encourage people to understand. > I think that the crux is that the promise constructor runs _synchronously_ > so when you pass it `this` it has not finished running yet. > > Of course, the workaround as domenic has pointed is to extract `resolve` > and `reject` from the `super` call since it is synchronous. > > (also I'm assuming you're not really mapping `(resolve, reject)` to > `this`? `this` is an object and the promise constructor ignores return > values anyway, you might as well pass a no-op in.) > > > > > _______________________________________________ > 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