Draft Specification of Streams API
Written by Kay Ewbank   
Tuesday, 19 February 2013

The W3C Web Applications Working Group has published the first public working draft of the Streams API, used for representing binary data in web applications as a Stream object.

The Streams API will give developers a way to programmatically build a stream and read its contents. The specification defines objects that can be used in threaded web applications for the synchronous reading of a Stream. It is designed to be used alongside other APIs and web elements such as XMLHttpRequest, postMessage, and Web Workers.

The API starts with a Stream interface. This represents a sequence of data that can be read over time. A Stream can come from APIs such as XMLHttpRequest, or can be built using StreamBuilder. The StreamReader interface has methods that you can use to read the contents of a Stream as a Blob, DataURL, ArrayBuffer, or as Text.

W3Clogo

The StreamReader interface is designed to run asynchronously on the user agent’s main thread, with an optional synchronous API to be used within threaded web applications. The asynchronous nature when reading Streams means you don’t run the risk of blocking and UI “freezing” on a user agent’s main thread. The event model used to read and access Streams is closely based on the FileReader interface. It provides asynchronous read methods through event handler attributes and the firing of events. The use of events and event handlers means you can set up separate code blocks to monitor the progress of the read and any error conditions that arise during the reading of the Stream.

The next element of the API is a StreamBuilder interface that you can use to create your own stream, pulling the contents from an internal buffer that you’ve created by appending Text, Blobs, or ArrayBuffers.

The API has extensions to XmlHttpRequest so you can use it to upload and download a Stream, and also extends createObjectURL and revokeObjectURL to add support for Stream.

 streamsalhambra

 

More Information

Streams API

Related Articles

Web Alarms API

Web Crypto APIs Work In Progress

W3C Draft For Device-Independent Input

W3C Publishes Push API Draft Specification

 

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

 

Banner


Grafana 11 Improves Metrics
11/04/2024

Grafana Labs, creators of the Grafana open-source metrics analytics and visualization suite, has announced the preview release of Grafana 11 with improvements to make it easier to view metrics, and ch [ ... ]



Azure AI And Pgvector Run Generative AI Directly On Postgres
26/03/2024

It's a match made in heaven. The Azure AI extension enables the database to call into various Azure AI services like Azure OpenAI. Combined with pgvector you can go far beyond full text search. Let's  [ ... ]


More News

Last Updated ( Tuesday, 19 February 2013 )