Re: [whatwg/streams] Provide a way for the underlying sink to signal write progress? (#876)

The specification currently states

> The [`WritableStream()`](https://streams.spec.whatwg.org/#ws-constructor) constructor accepts as its first argument a JavaScript object representing the [underlying sink](https://streams.spec.whatwg.org/#underlying-sink).

We can define a method at the JavaScript object passed to `WritableStream()` constructor

```
let WSController = class {
  constructor(/* data */) {
    this.bytesSoFar = 0;
  }
  progress(controller) {
    console.log(controller, this.bytesSoFar);
  }
  start(controller) {
    console.log(controller);
  }
  write(data, controller) {
    this.progress(controller, ++this.bytesSoFar);
  }
}

..

let wscontroller = new WSController();

let writableStream = new WritableStream(wscontroller);
```



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/876#issuecomment-375373268

Received on Thursday, 22 March 2018 16:39:09 UTC