Await for ReactPHP
This is simple await
implementation for ReactPHP. Whenever you need wait for a promise to be fulfilled in blocking manner, call await()
on it.
There is clue/block-react, which has more features, but breaks once there are more future ticks or timers on schedule. Also, this implementation restores running state of the loop.
Usage
// Inside running event loop:
$connector = new React\Socket\Connector($loop);
$connection = await($connector->connect('127.0.0.1:8080'), $loop);
try {
$connection = await($connector->connect('127.0.0.1:8080'), $loop);
} catch (RuntimeException $e) {
// Handling rejected promise.
}
Tests
vendor/bin/tester await.phpt
License
Package is licensed as MIT, see LICENSE.md.