yutakahirano / fetch-with-streams

Fetch API integrated with Streams.
66 stars 8 forks source link

Add the resource management specification. #26

Closed yutakahirano closed 9 years ago

yutakahirano commented 9 years ago

The user agent can terminate the fetch operation and reclaim associated resources if the response body stream is not reachable and there is not an active reader. #15

yutakahirano commented 9 years ago

@domenic, can you take a look at the change?

domenic commented 9 years ago

(review done :))

domenic commented 9 years ago

I would add this example:

// The user agent must not terminate the communication because there is an
// active reader. Even though the reader is not reachable by the garbage collector,
// the reader has been used to make termination observable, so if termination
// occurred on GC, that would make GC observable.
fetch("http://www.example.com/").then(res => {
  res.body.getReader().closed.then(() => console.log("stream closed!"));
});
yutakahirano commented 9 years ago

I would add this example:

Done.