Skip to content
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

Added async support to the interface. #969

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benelori
Copy link
Contributor

@benelori benelori commented Dec 18, 2021

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Documented? no
Fixed tickets #970
License MIT

This PR adds support for ReactPHP promises, because the wait() method of the current executor is synchronous and it will block the event loop.

This is more like a hack btw, because it's the first time I dove into the project and I needed something to work for my current work, which has ReactPHP.

I have issues with adding yet another flag to be honest and I'm not sure how to solve the issue with the controller, which will need to something like this in the createResponse method

if ($payload instanceof Promise) {
    return new ReactPromise(
        function ($resolve) use ($payload) {
            $payload
                ->then(
                    function (ExecutionResult $result) use ($resolve) {
                        $resolve(new JsonResponse($result->toArray(), 200));
                    },
                    function ($error) {
                        $reject($error);
                    }
                );
        }
    );
}

I would be glad to implement this properly, so I would like to ask for some opinions, on how this actually should look like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant