Re: [ServiceWorker] Can we change the body attribute of Request/Response to a method? (#606)

Response.body is a ReadableStream. The reader of ReadableStream calls ReadableStream.read() method only when ReadableStream.state is "readable". I want to start sending the content to the ServiceWorker, when some method is called. But there is no method to be called.

https://streams.spec.whatwg.org/#rs-intro
```javascript
function streamToConsole(readableStream) {
  readableStream.closed.then(
    () => console.log("--- all done!"),
    e => console.error(e);
  );

  pump();

  function pump() {
    while (readableStream.state === "readable") {
      console.log(readableStream.read());
    }

    if (readableStream.state === "waiting") {
      readableStream.ready.then(pump);
    }

    // otherwise "closed" or "errored", which will be handled above.
  }
}

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/606#issuecomment-70791964

Received on Wednesday, 21 January 2015 06:46:05 UTC