-
-
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
How to use await inside a class function? #62
Comments
PS: I use |
PROGRESS REPORT: private function processTradesAndApply($balanceArray, $userId): PromiseInterface
{
// Not Work Here
$S = $this->awaitLottieResizer(100, "IRT");
return $this->appManagerDatabase
->createSelectQuery(
"Trades",
['user' => $userId]
)->then(function ($result) use ($balanceArray, $userId) {
// Work Here But Stops the Loop
$S = $this->awaitLottieResizer(100, "IRT");
};
} |
a Better Question: |
@Parsoolak Thanks for bringing this up! This has been discussed in #20, #44, #49 and others before and this is more or less by design. As a rule of thumb, mixing blocking and non-blocking code should be avoided. This means these functions should only be used in a blocking application. If you're using a non-blocking application, you should use non-blocking primitives provided by promises and event emitters. If you're building an HTTP application, here's an example how this can be used with Framework X: I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can always reopen this 👍 |
I'm having some difficulty using
Block\await
function inreactphp
codes. I implemented this issue in 3 ways but either way it failed to do my task!Number 1
It will execute correctly but it close the connection and stops server
Number 2
It won't return anything and code stuck but the server is running
Number 3
It won't return anything and code stuck but the server is running
The text was updated successfully, but these errors were encountered: