-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Consistent event arguments and documentation #69
Conversation
README.md
Outdated
@@ -18,9 +18,11 @@ This component depends on `événement`, which is an implementation of the | |||
|
|||
### EventEmitter Events | |||
|
|||
* `data`: Emitted whenever data was read from the source. | |||
* `data`: Emitted whenever data was read from the source | |||
with a single mixed argument for incoming data. | |||
* `end`: Emitted when the source has reached the `eof`. | |||
* `error`: Emitted when an error occurs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous .
after occurs
. Also, probably remove the linebreak?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There you go! :-)
I've left the linebreak, as it does not show up in the rendered output and helps keeping the diff smaller. I'll file a follow-up PR that re-structures the documentation soon 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved already :)
src/ReadableStreamInterface.php
Outdated
@@ -5,9 +5,9 @@ | |||
use Evenement\EventEmitterInterface; | |||
|
|||
/** | |||
* @event data | |||
* @event data with single mixed argument for incoming data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with a single...?
src/ReadableStreamInterface.php
Outdated
* @event end | ||
* @event error | ||
* @event error with single Exception argument for error instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with a single...?
src/WritableStreamInterface.php
Outdated
@@ -6,9 +6,9 @@ | |||
|
|||
/** | |||
* @event drain | |||
* @event error | |||
* @event error with single Exeption argument for error instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with a single...?
src/WritableStreamInterface.php
Outdated
* @event close | ||
* @event pipe | ||
* @event pipe with single ReadableStreamInterface argument for source stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with a single...?
This simple PR changes it so that we only emit event arguments that are actually part of the event, i.e. we no longer emit the instance this event was emitted on. This was actually an undocumented feature, so some component may have relied on this.
Among others, this fixes several issues because these instance where never emitted consistently in the first place. In particular, the
forwardEvents
helper is used throughout React's ecosystem and has never actually updated the instances, as it has never checked any of the event arguments.I've updated the documentation to now explicitly state which arguments are actually passed to the event handlers.
Not passing these unneeded instances also helps with improving performance slightly. On my system, the benchmark examples went from ~1980 MiB/s to ~2020 MiB/s.
In case the instance the event was emitted on is needed, use a closure and pass it in manually.
Note that this is potentially a BC break in case anybody relied on the undocumented event arguments.