- From: Harald Alvestrand <notifications@github.com>
- Date: Wed, 03 Jul 2019 10:42:19 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/1004@github.com>
Domenic said this might be a good place to ask... I'm designing an API where I intend to use WHATWG Streams. I have to make a choice between a model where I show the user a bunch of readable/writable/transferStreams and tell the user "connect them all", and a model where I present a connected network of streams, and tell the user "make the changes you want". I experimented a little, and found that the code below didn't work - but I could find no obvious API to do what I wanted; once you have connected a stream, there seems to be no convenient API for reconnecting them, short of messing around with the readers and writers explicitly. Is there something obvious I'm missing? Thanks in advance! ``` var dest1 = new WritableStream({ write(chunk) { console.log('Dest 1 got ' + chunk); } }); var dest2 = new WritableStream({ write(chunk) { console.log('Dest 2 got ' + chunk); } }); var src = new ReadableStream({ start(controller) { const producer = () => { controller.enqueue('chunk'); setTimeout(producer, 1000); }; setTimeout(producer, 1000); } }); src.pipeTo(dest1); const pipeTo1 = () => { console.log('Piping to 1'); src.pipeTo(dest1); } const pipeTo2 = async () => { console.log('Piping to 2'); // Here there's something missing src.pipeTo(dest2); } ``` -- 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/1004
Received on Wednesday, 3 July 2019 17:42:41 UTC