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

Maybe a naive question, but is it required to specify a client for a request? I guess I'm not very clear about how this will be used, and wondering if there are other common values of client, or "this's relevant settings object" is sufficient in most cases if specifying client is required.

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

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

Received on Wednesday, 8 March 2023 23:42:59 UTC