Re: [whatwg/streams] What would happen if the data stream "pauses" then continues (see mode detail below) (#1008)

Thanks a lot @MattiasBuelens ~

One follow-up question: is there any way to change your code such that no async/await is used (for code-style reason)?

I tried as follows but did not work.

```
waitForData() {
    return new Promise(
        (resolve) => {
            if (this.position < this.source.length) {
                resolve();
            } else {
                return this.waitForData();
            }
        }
    )
}

append(newChunks) {
    this.source.push(...newChunks);
}

pull(controller: ReadableByteStreamController) {
    return this.waitForData().then(
        () => {
            const view = controller.byobRequest.view;
            view[0] = this.source[this.position++];
            controller.byobRequest.respond(1);
        }
    );
}
```

-- 
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/1008#issuecomment-519738903

Received on Friday, 9 August 2019 00:59:44 UTC