Re: [streams] Move stuff into controller to make RS and RBS closer (#418)

> So the readers are still owned by the stream? That is probably good, and simpler than what I was originally thinking of.

Yes. Operations on the reader is hidden to the controller.

> ReadableStream has:
>
> - state, reader, storedError, disturbed, and controller internal slots

Right.

> - AddReadRequestToReadableStream, GetNumReadRequests, RespondToReadRequest "spec internal methods" to allow the controller to manipulate its controlled readable stream (and its reader) without manipulating internal state directly.

Right. `[[state]]` and `[[storedError]]` are also visible to the controller but not manipulated directly by the controller.

> ReadableStreamController has:
> 
> - controlledReadableStream, underlyingSource, strategySize, strategyHWM, queue, started, closeRequested, pulling, pullAgain internal slots.
> - CancelReadableStreamController, EnqueueInReadableStreamController, ErrorReadableStreamController, GetReadableStreamControllerDesiredSize, ReadableStreamControllerCallPullIfNeeded, ShouldPullReadableStreamController "spec internal methods".

and `CloseReadableStreamController`. Currently they all contains "ReadableStreamController" in their names and the others don't.

Ah, I just noticed that in the last post I forgot to include `CancelReadable(Byte)StreamController` when listing the interfaces that controllers must implement.

> The eventual path forward, then, would be:
>
> - Convert ReadableStreamController's spec-internal methods into actual internal "methods", probably written something like ReadableStreamController@[[Cancel]](...). In source code we can name these _Close() and have them be methods in the class, which will be nice.

It's really nice! It'll be clear which operation belongs to which object.

> - Match up all controller internal methods so that both ReadableStreamController and ReadableByteStreamController have the same set of internal methods.
> - Convert ReadableStream to call this@[[controller]]@[[Cancel]](...), thus getting polymorphism for when we allow constructing ReadableStreams with ReadableByteStreamControllers, and merging the two classes.

Yes!

> 
> This sounds like it will work really well. There are probably some more complexities for the controller <-> reader interaction, but what you have so far makes sense.

Yeah. The interface adds complication but modularization would make each class easier to understand, I guess.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/418#issuecomment-165787656

Received on Friday, 18 December 2015 14:15:50 UTC