- From: Mattias Buelens <notifications@github.com>
- Date: Tue, 25 Jan 2022 13:56:12 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 25 January 2022 21:56:25 UTC
I've generalized the implementation a bit. I added two new helpers: * `readerAddStateChangeListener(reader, stateChangeListener)` * Calls `stateChangeListener` the next time `reader._stream._state` changes from `"readable"` to either `"closed"` or `"errored"`. * `writerAddStateChangeListener(writer, stateChangeListener)` * Calls `stateChangeListener` the next time `writer._stream._state` changes from `"writable"` to either `"closed"` or `"erroring"`. The `pipeTo()` reference implementation now uses these helpers instead of `reader._closedPromise` and `writer._closedPromise` to detect state changes. A `checkState()` helper checks the shutdown conditions when the pipe starts, and when the state of one of the streams changes. This should handle all possible synchronous state transitions, and check the shutdown conditions in the correct order as specified by the standard's text. (Perhaps we want to also use these helpers for `tee()`, and possibly eliminate the extra microtask from *readRequest*'s chunk steps there? I'll leave that for another time though. 😛) -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/1208#issuecomment-1021646391 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/pull/1208/c1021646391@github.com>
Received on Tuesday, 25 January 2022 21:56:25 UTC