Re: [heycam/webidl] Import the Promises Guide. (#772)

Ms2ger commented on this pull request.



>          1.  Let |R| be the first argument to |onRejected|.
         1.  Let |reason| be the result of [=converted to an IDL value|converting=]
             |R| to an IDL value of type {{any}}.
         1.  If there are no steps that are required to be run if the promise was rejected, then
             return <emu-val>undefined</emu-val>.
         1.  Otherwise, return the result of performing any steps that were required to be run if the promise was rejected,
             with |reason| as the rejection reason.
-    1.  Return [=!=] [$PerformPromiseThen$](|promise|, |onFulfilled|, |onRejected|).
+    1.  Let |onRejected| be [=!=] [$CreateBuiltinFunction$](|onRejectedSteps|, « »):
+    1.  Let |constructor| be |promise|.\[[Promise]].\[[Realm]].\[[Intrinsics]].[[{{%Promise%}}]].
+    1.  Let |newCapability| be ? [$NewPromiseCapability$](|constructor|).
+    1.  Return [=!=] [$PerformPromiseThen$](|promise|.\[[Promise]], |onFulfilled|, |onRejected|, |newCapability|).

Then PerformPromiseThen returns undefined.

> +    If any of the fetches fail, it will return [=Promise/rejected promise|a promise rejected with=]
+    that failure.
+
+    <pre highlight="webidl">
+        interface I {
+          Promise&lt;sequence&lt;Response>> batchRequest(sequence&lt;USVString> urls);
+        };
+    </pre>
+
+<div algorithm="batchRequest">
+
+    The <code>batchRequest(|urls|)</code> method steps are:
+
+    1.  Let |responsePromises| be « ».
+    1.  [=list/For each=] |url| of |urls|:
+        1.  Let |p| be the result of calling {{WindowOrWorkerGlobalScope/fetch()}} with |url|.

I think that's unnecessarily verbose.

-- 
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/pull/772#discussion_r317107379

Received on Friday, 23 August 2019 13:06:19 UTC