Skip to content

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.

1 participant