Augusto Moura (2018-07-20T16:15:24.000Z)
augusto.borgesm at gmail.com (2018-07-20T20:30:50.461Z)
I think what Jordan means, it's that the deferred has it use case, but probably we don't want it in Javascript native library. There's a lot of mature libraries implementing deferred wrappers and most of them are Promise like compatible, and even if you cannot use libraries or don't want to, you can easily implement a Promise extension and use it yourself. Interesting enough, I got a really weird case (reads contraintuitive, I'm pretty sure the semantics of the error are right) extending the Promise class to exemplify a simple Deferred implementation, the code: ``` js class Deferred extends Promise { constructor(factory) { super((resolve, reject) => { Object.assign(this, { reject, resolve }); factory(resolve, reject); }); } } const d = new Deferred(() => {}); ``` The problem is the usage of `this` before calling the super constructor (even when the using in the super call itself). I wonder with it there are any ways of capturing the super constructor arguments in a Base class using class syntax. You probably can get the arguments in a old "function class" syntax (can be done weakmaps too). We can probably start ~yet~ another thread on Promises, about this problem (supposing there's no way of passing `this` to the promise factory).