RE: [promises] Difficulties with using constructors and promises together

From: Boris Zbarsky [bzbarsky@MIT.EDU]

> Apart from it not being supported yet in WebIDL, and possibly looking a bit weird from the point of view of a JS programmer, is there something in principle that prevents "new Foo()" from returning a Promise<Foo>?

The problem with this would be that you generally expect

    Object.getPrototypeOf(new X) === X.prototype

and

    new X instanceof X

I guess that might have been what you mean by looking a bit weird.

--

IMO there are no great answers to this conundrum. `Foo.create` or maybe even a new `Foo.createAsync` convention might be the best way to go.

Received on Thursday, 20 June 2013 14:29:04 UTC