Skip to content

[Stream] Pass the stream as final parameter on 'drain'. #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 2, 2014
Merged

[Stream] Pass the stream as final parameter on 'drain'. #246

merged 2 commits into from
Feb 2, 2014

Conversation

jmalloc
Copy link
Contributor

@jmalloc jmalloc commented Dec 13, 2013

All the other events are passing the stream as the final parameter, except 'drain'.

@cboden
Copy link
Member

cboden commented Dec 21, 2013

A good change…would you mind applying this to the other drain emits (and full-drain) as well please?

@jmalloc
Copy link
Contributor Author

jmalloc commented Dec 21, 2013

Will do! There's other (ie, non-drain) events there that also don't pass the stream. I figure it should be done across all of the stream types since the event signature is more or less part of the interface. Is that reasonable?

@igorw
Copy link
Contributor

igorw commented Dec 21, 2013

@jmalloc since this is a bit more of a fundamental change, can you look at all the events, post a small summary and assess whether passing stream everywhere would make sense?

@jmalloc
Copy link
Contributor Author

jmalloc commented Dec 22, 2013

Sure, here are each of the event signatures as they are currently:

Event Signature Classes
close [] Buffer
close [this] ReadableStream, WritableStream, Stream
data [data, this] Stream
data [data] ThroughStream
drain [] Buffer, Stream
end [this] ReadableStream, WritableStream, Stream
error [error] Buffer
error [error, this] Stream
full-drain [] Buffer
pipe [source] CompositeStream, ReadableStream, Stream

Given how easy it is to use a closure as a handler obviously it's not imperative that the stream be passed on every event, but I can't think of any downside. At the very least close, data and error, which have multiple signatures currently, should have matching signatures across implementations.

pipe might be the one event where passing the stream doesn't make much sense as currently only the emitters of this event are listening to themselves, which I think is a product of the logic for piping being implemented in Util. At any rate I can't think of a strong argument for not passing the stream.

@jmalloc
Copy link
Contributor Author

jmalloc commented Feb 2, 2014

All of the streams mentioned in the table above now have consistent event parameters.

While I was doing this I realised there's a few stream implementations in other namespaces (HTTP requests/responses, etc) that are a bit different again, some of those events introduce new parameters entirely so I don't think I'll attempt to address that in this PR.

@cboden
Copy link
Member

cboden commented Feb 2, 2014

👍

@igorw, @nrk good?

igorw added a commit that referenced this pull request Feb 2, 2014
[Stream] Pass the stream as final parameter on 'drain'.
@igorw igorw merged commit 0c8eaec into reactphp:master Feb 2, 2014
@igorw
Copy link
Contributor

igorw commented Feb 2, 2014

Merged.

@jmalloc jmalloc deleted the stream-drain-event branch February 2, 2014 21:22
@cboden cboden added the stream label Feb 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy