Re: [whatwg/streams] Why are [[writeRequests]] and [[queue]] separate? (#589)

I tried to have the ReadableStream (and readers) and WritableStream (and writers) contain only the logic to represent the constraints of the interfaces and have the controllers hold the remaining part i.e. helper functionality for source/sink implementors.

It's up to the sink implementor how to maintain the written chunks. The byte-stream variant to be introduced may detach the passed values, and in such case, it doesn't make much sense to hold them inside the WritableStream. On the other hand, it's one of the constraints of WritableStream interface that:
- each write() and close() returns a promise,
- they'll be fulfilled/rejected in the same order,
- they'll get rejected on error

So, I represented these in the WritableStream class using `[[writeRequests]]` in it, the abstract operations as members of the WritableStream, and assertions in them. We can, of course, ask the sink implementor (including the controller) to follow these constraints in the form of more assertions or spec texts, but the point is that it's better that we represent them as code inside the WritableStream class as much as possible.


-- 
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/589#issuecomment-258342267

Received on Friday, 4 November 2016 04:25:18 UTC