W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

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

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Thu, 20 Jun 2013 14:28:28 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>, "www-dom@w3.org" <www-dom@w3.org>
Message-ID: <B4AE8F4E86E26C47AC407D49872F6F9F8780C923@BY2PRD0510MB354.namprd05.prod.outlook.com>
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


    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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:02 UTC