Re: [whatwg/streams] Teeing dynamically (#979)

`tee()` is definitely a high-level helper. Although it's a bit more flexible than you mention (e.g. you could read four chunks, then unlock and call `tee()`), it doesn't cover all possible cases of multiple output streams.

I'd suggest building your thing using the more flexible, but still fairly high-level, `pipeTo()`. E.g.:

```js
rs.pipeTo(new WritableStream({
  write(chunk) {
    // Send chunk to all currently-in-play destinations
  },
  close() {
    // Close all currently-in-play destinations
  }
});
```

You could even create a `WritableStream` subclass to make this easier, e.g. with some work you could end up with the following code:

```js
const dest = new BroadcastWritableStream();
rs.pipeTo(dest);

// ... elsewhere ...
dest.add(someWritableStream);
dest.add(someOtherWritableStream);
dest.remove(someWritableStream);
```

Make sense?

-- 
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/issues/979#issuecomment-454149523

Received on Monday, 14 January 2019 20:27:54 UTC