Re: [whatwg/fetch] Return a "controller" instance from fetch (#1329)

@annevk commented on this pull request.



> @@ -255,6 +258,29 @@ given a <a for=/>fetch timing info</a> <var>timingInfo</var>, return a new
  <var>storedTimingInfo</var>'s <a for="fetch timing info">decoded body size</a>.
 </ol>
 
+<p>To <dfn for="fetch params">abort</dfn> a <a for=/>fetch params</a> <var>fetchParams</var>,
+set <var>fetchParams</var>'s <a for="fetch params">fetch state</a> to "<code>aborted</code>".
+
+<p>To <dfn for="fetch params">terminate</dfn> a <a for=/>fetch params</a> <var>fetchParams</var>,
+set <var>fetchParams</var>'s <a for="fetch params">fetch state</a> to "<code>terminated</code>".
+
+<p>A <a for=/>fetch params</a> <var>fetchParams</var> is <dfn for="fetch params">canceled</dfn> if
+its <a for="fetch params">fetch state</a> is "<code>aborted</code>" or "<code>terminated</code>".
+
+<p>A <dfn export>fetch controller</dfn> is an object used to enable clients of an ongoing fetch
+to perform certain actions in the context of that fetch instance.

It seems a bit weird for state to be terminated. But I do like this idea. Can it instead be the controller that holds the state? And fetch params / fetch record have a reference to the controller?

And if we need to expose more things on the controller in due course, we could do that this way? And only expose it at the appropriate time, etc.

That does seem somewhat cleaner than having an internal slot and hiding it by not exporting it.

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

Received on Monday, 1 November 2021 10:05:14 UTC