-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Promise not working as async without wait() #89
Comments
I am having the same issue. Any solutions, yet? |
From what I can tell, you are trying to call multiple promises at once and wait for them to return? If this is the case, there is an https://github.com/guzzle/promises/blob/master/src/functions.php
|
I been working on just this problem intermixed with #44 (comment) and reactphp/promise#66. According to promises-aplus/constructor-spec#18 the constructor implemented here is invalid. ReactPHP is valid to those spec's, but it will fail at runtime on your code example, and most Guzzle promise tests that tries to access an promise reference object of itself, it will produce an runtime error, access member method on null. In order for your promise to work async, something like the following needs to be added to the constructor:
This will end up producing an valid constructor according to spec's. It basically traps the otherwise error, and adds the callback to the event queue. However, it solves and introduces a few problems and wait method will need refactoring. My In my For more background, the process I took started on another promise library in Sabre.io sabre-io/event#66, which is similar to ReactPHP implementations, but had an wait method not constructed like Guzzle here. Since ReactPHP have no real promise tests or examples, reactphp/promise#103, reactphp/promise#127, reactphp/promise#91, just a lot of mock tests. I used Sabre.io, and Guzzle promise tests, the ones it should pass, and ReactPHP fails some tests it shouldn't. There implementations should pass similar coded examples, if following JavaScript promise spec's. I will submit PR, only if requested. The other main change I made was to easily use any event loop implementation as reactphp/promise#64. The wait method here is an forethought of the whole library to function, not an afterthought feature, that i find, can't be easily rewrote/refactored. |
The code works if i do $promise->wait();, however i am not sure how can i call the promise to work async.
The text was updated successfully, but these errors were encountered: