I think this looks like a great idea for handling streaming of the
On Jan 25, 12:41 am, "Isaac Z. Schlueter" <i...@foohack.com> wrote:
> Hey, what do you guys think of this? A worthwhile direction to
> pursue?
>
> If a promise is like the async version of a function, then it seems a
> parallel metaphor to think of an event emitter as sorta like the async
> version of an object with specific fields. To "read" the field, you
> attach a listener. To have one object mirror another, you can just
> listen to the events you care about, and then re-emit them on the
> watcher object.
body. Of course, I think it is pretty critical that there is support
for asynchronously returning the status and headers, especially for
use in Node. I didn't see any examples of that in your code (the
status and headers were always returned synchronously). Can I presume
that one would follow JSGI 0.3's use of promises for the response
object to defer the status and headers, and then use your streaming
body pattern for the sending the body? If so, that sounds like it
could be a cool combination (although the synchronous streaming
scenario seems like it could induce undesirable buffering).
We made a single request object handle both request and response. It
is a stream with event emitter semantics. When a stream becomes
writable it issues a "writable" event and similarly for "readable".
For write, you want to know when the stream can accept more data
without blocking. Node buffers all write data, but I think a better
API is to get a writable event and to allow writes to return short.
This is more standard Posix semantics. Similarly for read.
What are you proposing to do?