resend/fwd of accidental personal reply

Hello Medikoo,

You seem to misunderstand what async functions do to be async. Your
function has the same product as the following:

new Promise((acc, rej) => acc(extendedPromise))

A promise that resolves to a extendedPromise instance. By no means do async
functions use the returned values as their way of determining what type of
promise they are: that'd break when using multiple returns with different
types.

I hope this explains it a bit for you.

-Matthias

On 14 Apr 2017 09:58, "medikoo" <[email protected]> wrote:

While Promise methods and functions are friendly for it's extensions (or
even not direct extensions but just thenables), the async function will
always normalize it's result to instance of Promise, even it's
ExtendedPromise, e.g.: class ExtendedPromise extends Promise {}; var
extendedPromise = new ExtendedPromise(function (resolve) { resolve(); });
extendedPromise.then().constructor === ExtendedPromise // true var asyncFn
= async function () { return extendedPromise; }; asyncFn().constructor ===
ExtendedPromise // false asyncFn().constructor === Promise // true That
makes it cumbersome if we work with promise extensions. What was the
reasoning behind such design? If not thenables in general, the promise
extensions I believe should be passed through (or copied via its
constructor.resolve).
------------------------------
View this message in context: Async functions not friendly to promise
extensions
<http://mozilla.6506.n7.nabble.com/Async-functions-not-friendly-to-promise-extensions-tp364921.html>
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive
<http://mozilla.6506.n7.nabble.com/Mozilla-ECMAScript-4-discussion-f89340.html>
at Nabble.com.

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to