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

> So to be clear, the usage would be something like this?

Yes, exactly.  (Or munging several into a Promise.all(), etc.)

> Are all constructors of an interface required to be async if any are?

I suspect we'd want to make that restriction, yes. "Multiple" constructors are just a syntax nicety for doing type-checking over complicated argument lists; they're all implemented as a single JS function.  If we pretend that this function is designated `async` in JS syntax, then there's no way to return a non-Promise.

> This is possible today in non-IDL JS... are there examples of libraries that do this?

Dunno! This should be investigated.

-- 
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-394036231

Received on Friday, 1 June 2018 23:40:50 UTC