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.