Re: [whatwg/webidl] Introduce "mark as handled" for promises (PR #1090)

@annevk commented on this pull request.



>  </div>
 
-This phrase is useful when you wish to aggregate the results of multiple promises, and then produce
-another promise from them, in the same way that {{Promise/all()|Promise.all()}} functions for
-JavaScript code.
+<div algorithm>
+    To <dfn export lt="mark a promise as handled|mark as handled">mark as handled</dfn> a
+    <code><a interface>Promise</a>&lt;<var ignore>T</var>&gt;</code> |promise|, set
+    |promise|.\[[Promise]].\[[PromiseIsHandled]] to true.
+
+    <p class="note">This definition is useful for promises which you expect rejections to often be

for which you expect?

>  </div>
 
-This phrase is useful when you wish to aggregate the results of multiple promises, and then produce
-another promise from them, in the same way that {{Promise/all()|Promise.all()}} functions for
-JavaScript code.
+<div algorithm>
+    To <dfn export lt="mark a promise as handled|mark as handled">mark as handled</dfn> a
+    <code><a interface>Promise</a>&lt;<var ignore>T</var>&gt;</code> |promise|, set
+    |promise|.\[[Promise]].\[[PromiseIsHandled]] to true.
+
+    <p class="note">This definition is useful for promises which you expect rejections to often be
+    ignored; it ensures such promises do not cause {{Window/unhandledrejection}} events. The most
+    common use case is for promise properties, which the web developer might or might not consult.
+    An example is the {{WritableStreamDefaultWriter/closed|writableStreamWriter.closed}} promise,
+    which is [=marked as handled=] immediately after it is [=rejected=].

Would it make sense to offer an operation that rejects and marks as handled as a combined operation? Or are there cases where they need to be disjoint?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1090#pullrequestreview-865808580
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1090/review/865808580@github.com>

Received on Friday, 28 January 2022 08:22:14 UTC