reactphp / promise

Promises/A implementation for PHP.

Home Page:https://reactphp.org/promise/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

please tell me whether you can track the performance of the promise on time?

StasToken opened this issue · comments

hello - please tell me whether you can track the performance of the promise on time?
for example we have the terms of which
reject - if the operation was performed for more than 60 seconds
resolve - if the operation was performed less than 60 seconds
I know that in nodejs this can be done, but is it possible to do this on PHP if so how is there an example?

Hi @StasToken! I'm not sure I follow what you're trying to do, it sounds like you may be looking for a timeout() function? Have you seen https://github.com/reactphp/promise-timer#timeout yet?

You can use this like this:

$promise = anyOperation();

\React\Promise\Timer\timeout($promise, 60, $loop)->then(function ($result) {
    // resolved within 60s
    var_dump($result);
});

I hope this helps 👍

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 reopen this 👍

no works - timeout
Code example: https://pastebin.com/TTkcjpcm
Does not work timeout it can not find it, maybe I'm not connecting it right? can a complete example be possible if it does not make it difficult for you? I'm still a novice in this business

PHP Fatal error: Uncaught Error: Call to undefined function React\Promise\Timer\timeout() in...

I'm stupid - all work...