-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenericTransformStream mixin vs. subclassing #1074
Comments
See whatwg/encoding#72 (comment) and so on for the historical background. I'd summarise it as: subclassing from TransformStream places constraints on implementations that don't benefit users. In the case of ReadableStream and WritableStream there's a lot of stuff you get from subclassing, but TransformStream is just a {readable, writable} pair. Since this debate happened, there have been a few relevant developments:
I still prefer to have the GenericTransformStream mixin. Maybe we could make TransformStream include the mixin as well? |
Right, OK, thank you for digging that up. My main concern is that, looking at the section I wrote up in #1073, it looks kind of pointless. The wrapping is basically isomorphic to subclassing; instead of setting up
This doesn't work, because then every TransformStream would have an associated
This is pretty interesting, but I'm not sure how to think about how it interacts with the above concerns. (It does indicate that |
Closes whatwg#1084 by encouraging use of "set up" instead. Also partially addresses whatwg#1074 by softening the language about subclassing vs. mixins.
#1073 works to formalize and formally recommend the pattern used by https://encoding.spec.whatwg.org/ and https://wicg.github.io/compression/, of wrapping up an internal
TransformStream
and re-exposing it throughreadable
andwritable
properties.However, I've lost track of why we do this, instead of subclassing
TransformStream
.NativeFS shows how to subclass
WritableStream
, and #1073 makes it much easier by allowing you to reduce much of the boilerplate there to[=WritableStream/Set up=] [=this=] with |writeAlgorithm| and |closeAlgorithm|
. It seems we could similarly make subclassingTransformStream
easy.This isn't very consequential. In general I expect the most noticable effect to be on
instanceof
. I don't expect us to add any significant public APIs toTransformStream
that we'd want subclasses to inherit.However, I am a bit concerned about recommending a totally different pattern for
TransformStream
than we do forWritableStream
andReadableStream
. So I thought it'd be worth raising, and seeing if perhaps we want to change course.The text was updated successfully, but these errors were encountered: