Re: [whatwg/fetch] Editorial: Reword how-to section to explain how to use callbacks & controller (PR #1614)

@qingxinwu commented on this pull request.



> +  <p>This is the most common way in which clients handle a <a for=/>response</a>, for example
+  <a lt="fetch a classic script">scripts</a> and <a lt="fetch a style resource">style resources</a>.
+  The <a for=/>response</a>'s <a for=response>body</a> is downloaded in its entirety into a
+  <a>byte sequence</a>, and then processed by the <a for=request>client</a>.
+
+  <p>To process a <a for=/>response</a> upon completion, pass an algorithm to the
+  <a for=fetch><i>processResponseConsumeBody</i></a> argument of <a for/>fetch</a>. The given
+  algorithm accepts a <a for=/>response</a> and the final contents.
+  The final contents could be null if there was
+  a <a>network error</a>, failure if there was an error while downloading, or a <a>byte sequence</a>
+  representing the successfully downloaded <a for=response>body</a>.
+
+  <div id=example-callback-upon-completion class=example>
+   <ol>
+    <li><p>Let <var>request</var> be a <a for=/>request</a> whose <a for=request>URL</a> is
+    "https://stuff.example.com", and whose <a for=request>client</a> is <a>this</a>'s

ah thanks, the previous section is quite clear about it, and thanks for the explaination!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1614#discussion_r1130400091
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1614/review/1331959342@github.com>

Received on Thursday, 9 March 2023 04:12:51 UTC