On Jun 2, 2015, at 8:08 PM, Logan Smyth wrote:
To clarify things, since I don't think it's been made abundantly clear, the
example that Sebastian gave would work in a standard ES6 environment,
correct? It is only if the callback were executed synchronously that the
exception would be
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. I think that the crux is
that the promise constructor runs _synchronously_ so when you pass it
`this`
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
It seems like, at least in the case with Promise, it could be solved also
by having the this binding of the executor bound to the promise or have the
promise object passed into the executor as a third argument maybe?
On Jun 2, 2015 10:38 PM, Brendan Eich bren...@mozilla.org wrote:
With best
This is a limitation of Babel and not at all a reflection of the actual
specification. This restriction is imposed order to follow ES2015 semantics of
not being able to reference `this` before `super()`. It does a pretty dumb
check of only allowing it to be strictly after the call (ie. not
Hmm I am pretty sure Babel et al. are correct here in not allowing this. The
super call needs to *finish* before you can use `this`. Chrome also works this
way.
The correct workaround is
```js
let resolve, reject;
super((a, b) = {
resolve = a;
reject = b;
});
// use this
```
Ah, completely right. At first glance I thought it was this similar but
separate issue:
```js
class Foo {
constructor(callback) {
this.callback = callback; // just storing it!
}
}
class Bar extends Foo {
constructor() {
super(() = this); // reference to `this` will
If I thought I could make any money then I would most definitely bet that
the changes made to classes that are at the root of this problem will be
the undoing of es classes and I find myself feeling more and more like
avoiding them is the easiest thing to do.
This use-case is a perfect example of
To clarify things, since I don't think it's been made abundantly clear, the
example that Sebastian gave would work in a standard ES6 environment,
correct? It is only if the callback were executed synchronously that the
exception would be thrown since the `this` binding has not yet been
Hi Logan - that's correct.
On Tue, Jun 2, 2015 at 11:08 PM Logan Smyth loganfsm...@gmail.com wrote:
To clarify things, since I don't think it's been made abundantly clear,
the example that Sebastian gave would work in a standard ES6 environment,
correct? It is only if the callback were
With best intentions I must say that you are overreacting. The
subject-line code (h/t Mark Miller for pointing me at it!) in context of
the superclass constructor uses `this` before `super` has returned.
That's a no-no for pretty-good reason.
If you have a better alternative design, we needed
11 matches
Mail list logo