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

Domenic Denicola <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <B4AE8F4E86E26C47AC407D49872F6F9F8780C923@BY2PRD0510MB354.namprd05.prod.outlook.com>
From: Boris Zbarsky [[email protected]]

> 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.