Re: Overlap between StreamReader and FileReader

On Fri, May 17, 2013 at 9:38 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> For Stream reading, I think I would do something like the following:
>
> interface Stream {
>   AbortableProgressFuture<ArrayBuffer> readBinary(optional unsigned
> long long size);
>   AbortableProgressFuture<String> readText(optional unsigned long long
> size, optional DOMString encoding);
>   AbortableProgressFuture<Blob> readBlob(optional unsigned long long size);
>
>   ChunkedData readBinaryChunked(optional unsigned long long size);
>   ChunkedData readTextChunked(optional unsigned long long size);
> };
>
> interface ChunkedData : EventTarget {
>   attribute EventHandler ondata;
>   attribute EventHandler onload;
>   attribute EventHandler onerror;
> };

Actually, we could even get rid of the ChunkedData interface and do
something like

interface Stream {
  AbortableProgressFuture<ArrayBuffer> readBinary(optional unsigned
long long size);
  AbortableProgressFuture<String> readText(optional unsigned long long
size, optional DOMString encoding);
  AbortableProgressFuture<Blob> readBlob(optional unsigned long long size);

  AbortableProgressFuture<void> readBinaryChunked(optional unsigned
long long size);
  AbortableProgressFuture<void> readTextChunked(optional unsigned long
long size);
};

where the ProgressFutures returned from
readBinaryChunked/readBinaryChunked delivers the data in the progress
notifications only, and no data is delivered when the future is
actually resolved. Though this might be abusing Futures a bit?

/ Jonas

Received on Saturday, 18 May 2013 04:58:00 UTC