Re: [heycam/webidl] Async constructors? (`new Foo()` returning Promise<Foo>) (#563)

While `await new` does look pretty clean if nonidiomatic, using `.then` and `.catch` looks a bit odd:

```js
return new StyleSheet(text).then(actualSheet => actualSheet.doSomethingElse());
```

In general I would prefer preserving the `new` keyword to what's already there rather than introducing something new into the platform. I would not be surprised at all to find style guides out there that expressly prohibit `return`ing from a constructor – and in fact I would suggest the same to most JavaScript programmers.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/563#issuecomment-394037643

Received on Friday, 1 June 2018 23:52:51 UTC