-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
[RFC] Functional API #5
Comments
Some random thoughts:
|
Also, regarding functional composition: Quite a bit of the current API can probably be replaced with a somewhat simpler functional approach. For example, the function awaitAll(array $promises, LoopInterface $loop)
{
return awaitOne(Promise\all($promises), $loop);
} (Though this skips cancellation for now, see also #4) To be clear: I'm not saying this can not be done with our current OOP API, but the functional API certainly makes this more obvious. |
To expand on the previous comment, we might also consider if we should reduce our API to a single
It's sufficiently easy to call the following functions yourself:
|
Also, combined with https://github.com/clue/php-promise-timeout, it's pretty easy to add timeout support to any of the above (see also #2):
Arguably, the
Similarly, this also applies to slightly more complicated combinations:
|
The current OOP API looks a bit flawed IMO.
This ticket serves as a discussion basis whether it makes sense to use plain functions instead.
Current API:
Suggested API (prototype):
The text was updated successfully, but these errors were encountered: