- From: Adam Rice <notifications@github.com>
- Date: Fri, 05 Aug 2016 00:58:55 -0700
- To: whatwg/streams <streams@noreply.github.com>
Received on Friday, 5 August 2016 08:25:48 UTC
If you stop trying to make it be a push source, it gets much simpler and closer to the C API:
```javascript
start(controller) {},
pull(controller) {
// This is called when the internal queue has been drained, and the
// stream’s consumer can accept more data.
return socket.select()
.then(() => {
const v = controller.byobRequest.view;
try {
const bytesRead = socket.read(v.buffer, v.byteOffset, v.byteLength);
if (bytesRead === 0) {
controller.close();
} else {
controller.byobRequest.respond(bytesRead);
}
} catch (e) {
controller.error(e);
}
});
}
```
This probably defeats the purpose of the example, however.
---
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/pull/504#issuecomment-237781915
Received on Friday, 5 August 2016 08:25:48 UTC