Re: [whatwg/streams] Add examples of using identity transforms to manipulate streams (#847)

ricea commented on this pull request.



> +        .then(() => readable.pipeTo(ts.writable, { preventClose: true }),
+              reason => {
+                return Promise.all([
+                  ts.writable.abort(reason),
+                  readable.cancel(reason)]);
+              });
+  }
+  promise.then(() => ts.writable.getWriter().close(),
+               reason => ts.writable.abort(reason))
+      .catch(() => {});
+  return ts.readable;
+}
+</code></pre>
+
+The error handling here is subtle because cancelling the concatenated stream has to cancel all the intput
+streams. However, the success case is simple enough. We just pipe each stream in the <code>readables</code> array one at

It's not really helpful to leave some of them open, as the caller has no way to detect which ones have been closed.

Since this is an important primitive, I'd like to have a fully correct implementation, or no implementation at all. I expect in the future we will have a static method called `ReadableStream.concatenate()` or similar that does this exact thing.

-- 
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/streams/pull/847#discussion_r147908955

Received on Tuesday, 31 October 2017 07:08:02 UTC