Re: [streams] Real time source and skipping (#383)

One last thing. Perhaps the mismatch comes from

> real-time, they generate frames constantly no matter what, e.g. a webcam. These sources would probably use push semantics

It depends on whether the webcam stream is "recording" or "live". If it is recording, then the whole sequence is valuable, and you don't want to throw away any data, so much of this discussion is moot. If it is live, then I would expect its source to be implemented much more like an on-demand stream, like so:

```js
new ReadableStream({
  start(c) {
    rawWebcam.onNewFrame = frame => {
      this.currentFrame = frame;
    };
  }
  
  pull(c) {
    c.enqueue(this.currentFrame);
  }
});
```

This will mean that every `read()` corresponds to a `pull` which immediately (synchronously) enqueues the current frame, allowing it to be read by the consumer instantly. Frames are skipped, but that's fine.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/383#issuecomment-127382724

Received on Monday, 3 August 2015 19:39:03 UTC