Promise sub-class: super((resolve, reject) => this) ?
benjamingr at gmail.com
Wed Jun 3 08:27:38 UTC 2015
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` 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.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss