Intent to Implement: WritableStream (part of Streams API)

138 views
Skip to first unread message

Adam Rice

unread,
Oct 28, 2016, 8:49:07 AM10/28/16
to blink-dev

Contact emails

ri...@chromium.org, tyos...@chromium.org (implementation); dom...@chromium.org (spec)


Spec

The Streams Standard, WritableStream section: https://streams.spec.whatwg.org/#ws



Summary

WritableStream is the writable counterpart to ReadableStream (which shipped in 2015). It provides a standard abstraction for writing streaming data to a sink, with backpressure and queuing. Sinks can be either built-in or implemented in Javascript.


Motivation

The Streams API provides a standard API and terminology for dealing with streaming data in the browser, replacing the ad hoc designs and implementations that have been used up until now. WritableStream addresses one part of the requirements.


Developers can easily create custom sinks, for example wrapping IndexedDB, HTTP endpoints or WebSockets. They can then easily interoperate with the platform's existing exposed readable streams.


Once we have writable streams, we can implement transform streams, which have many applications such as streaming text encoding and decoding, on-the-fly compression, transcoding, transforming legacy data formats into JSON, etc.


Writable streams also unlock the implementation of pipeTo, which makes composition of streams trivial. See https://streams.spec.whatwg.org/#example-pipe-as-chunks-receiver for an example.


Interoperability Risk

Low.


Gecko and WebKit representatives have been actively involved in discussion of the spec. We have already developed a large suite of web platform tests with high coverage against the reference implementation. We intend to upstream these tests to the w3c web-platform-tests repository soon, as been done for readable streams; for now they are being iterated on inside the spec repo. WebKit developers have also been participating in authoring web-platform tests.


ReadableStream has already paved the way with excellent interoperability. It is currently shipping in Edge, WebKit, and Blink with compatible semantics, with Gecko following close behind.


Compatibility Risk

Low.


The WritableStream standard has stabilised. There has been a lot of activity with new tests being written and editorial adjustments in the last month, none of which has made breaking changes to the API.


The pending spec issues can be found at in the spec repository. The remaining discussions are about minor details and future extensions, which won't break existing code.


Ongoing technical constraints

None.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes.


OWP launch tracking bug

https://bugs.chromium.org/p/chromium/issues/detail?id=658144


Link to entry on the feature dashboard

https://www.chromestatus.com/feature/5928498656968704


Requesting approval to ship?

No.

Reply all
Reply to author
Forward
0 new messages