- From: Takeshi Yoshino <notifications@github.com>
- Date: Thu, 09 Apr 2015 00:26:53 -0700
- To: whatwg/streams <streams@noreply.github.com>
Received on Thursday, 9 April 2015 07:27:23 UTC
> 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