Re: [streams] Readable stream with ack (#324)

> However, I find it basically impossible to envision author code using this correctly and consistently.

I agree it's not easy to use. The user must be aware of some contract.

> illustrate some author code

Sure

```
// Producer
let id = ...;  // Identity transform
let abv = ...;  // Data to write. Wanna get it back once I/O finishes consuming its contents.
let p = id.writable.write(abv);
p.then(abv => {
  // Reuse abv
});

// Consumer
let descriptor = id.readable.read();
let abv = descriptor.value;
sendToNetwork(abv).then(abv => {
  // Now, sendToNetwork finished consuming all the contents and returned
  // the ownership of the ArrayBuffer to us.
  descriptor.resolve(abv);
});
```

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

Received on Thursday, 9 April 2015 07:27:23 UTC