-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add static Loop methods #229
Conversation
@@ -47,4 +47,154 @@ public static function set(LoopInterface $loop) | |||
{ | |||
self::$instance = $loop; | |||
} | |||
|
|||
/** | |||
* [Advanced] Register a listener to be notified when a stream is ready to read. |
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.
Why are only adding streams marked as advanced? IMHO if we mark those two we should also mark removeReadStream
&& removeWriteStream
as such. And maybe mention react/stream for easier usage.
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.
Fair point. I've applied the exact same documentation from the LoopInterface::addReadStream()
method:
event-loop/src/LoopInterface.php
Line 8 in 1a709e2
* [Advanced] Register a listener to be notified when a stream is ready to read. |
Your suggestion sounds perfectly reasonable, perhaps file this as a follow-up PR to also adjust the interface and the README (similar to #110)? 👍
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.
Will do 👍
Rebased on |
Updated to move deprecation notices out of this PR and split this up into a dedicated PR #231. To ease review, this PR here now only deals with the new static methods. (Merging either PR will likely cause a merge conflict with the other PR, but I'd rather put the burden of rebasing and fixing this conflict onto myself than the people reviewing this.) |
This changeset adds static Loop methods. The Loop class now provides all methods that exist on the LoopInterface as static methods:
This is particularly useful when directly interfacing with the event loop in application code. I've also updated the documentation to highlight some use cases where the
Loop::get()
method would still be useful when using dependency injection (DI).Builds on top of #226