>
> If you add a `readable` handler, then `'readable'` (and potentially
> `'end'`, if there's no data) will be emitted.
>

Then there's a bug.


> > So the readable event is more of an advisory event. The docs should
> probably say something about how you could possibly miss the event entirely
> if you're doing some other IO before you try and read from the stream.
>
> The docs don't say that because it's not true.  (Unless, of course,
> someone *else* is listening for it, or reading from it, but then it's
> not really *your* stream, now, is it?)
>
> This is perfectly safe:
>
> ```
> net.createServer(function(sock) {
>   doSomeIOandTHEN(function() {
>     sock.on('readable', function() {
>       readStuff(sock)
>     })
>   })
> })
> ```
>

Thanks for confirming. I was under the impression that this is how the API
is supposed to work, but was confused because that's not what I'm seeing on
node 0.10.1. I've filed an issue<https://github.com/joyent/node/issues/5141> so
we can continue the discussion there. The example code in the ticket
confirms that nobody else is listening for the `readable` event or reading
from the stream, so we can safely assume that the stream is in fact *my*
stream and rule that out.


> > It seems like we get to pick one API or the other. I can make all of my
> code use the new API or I can abuse the reverse compatibility, either way
> I'm only using one API.
>
> I don't see how you can call this "abuse", really.  It's not as if
> there's "new API" and "old API" living side by side here.  There's
> just "The API".  It's not bad to use any part of it.
>

Then we probably shouldn't call it an "old" API in the docs. In a
fast-moving target like node, using any API that is called "old" in the
docs just feels like instant technical debt.


> > Part of the reason I was so excited about streams2 is that I thought it
> meant I could finally deprecate BufferedStream in favor of 0.10's Readable.
>
> Part of the reason we wrote streams2 was so that you could deprecate
> BufferedStream :)
>

Gladly, once I can see that it's working! :D


> It could mean that the docs are lacking, and as you
> know, help is always welcome there.  If you find a question not
> answered by the documentation, send a doc patch with the answer when
> you do find it.
>

Absolutely. But if we all can't agree what the expected behavior is, then
it seems a bit premature to send pull requests for the docs. That's in part
what I'm using this mailing list for. To ping other people and see how
*they* think the APIs work. So far in this thread we've already had several
misunderstandings about how things work in streams2. Once I can actually
*confirm* something one way or the other I'm more than happy to put it in
the docs.


> > Looking back, the data/pause/resume/end/error API isn't too bad.
>
> And it's still there.  It's not wrong to use it.
>

If I can't see the readable event (see the ticket I filed above) then it's
not only "not wrong" to use pause/resume but actually *necessary* in
certain cases.

--
Michael Jackson
@mjackson

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to