promises: Add a comment explaining a subtlety in `Gate`
parent
a115c475ad
commit
fa8bdb0348
|
@ -65,6 +65,9 @@ class Gate extends Promise {
|
||||||
static get [Symbol.species]() { return Promise; }
|
static get [Symbol.species]() { return Promise; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
// `this` is assigned when `super()` returns, not when it is called, so it is not acceptable to
|
||||||
|
// do the following because it will throw a ReferenceError when it dereferences `this`:
|
||||||
|
// super((resolve, reject) => Object.assign(this, {resolve, reject}));
|
||||||
let props;
|
let props;
|
||||||
super((resolve, reject) => props = {resolve, reject});
|
super((resolve, reject) => props = {resolve, reject});
|
||||||
Object.assign(this, props);
|
Object.assign(this, props);
|
||||||
|
|
Loading…
Reference in New Issue