@@ -422,15 +422,13 @@ $promise = Queue::any(10, $jobs, array($browser, 'get'));
422422#### Blocking
423423
424424As stated above, this library provides you a powerful, async API by default.
425- If, however, you want to integrate this into your traditional, blocking
426- environment, you may want to look into also using
427- [ clue/reactphp-block] ( https://github.com/clue/reactphp-block ) .
428425
429- The resulting blocking code that awaits a number of concurrent HTTP requests
430- could look something like this:
426+ You can also integrate this into your traditional, blocking environment by using
427+ [ reactphp/async] ( https://github.com/reactphp/async ) . This allows you to simply
428+ await async HTTP requests like this:
431429
432430``` php
433- use Clue\ React\Block ;
431+ use function React\Async\await ;
434432
435433$browser = new React\Http\Browser();
436434
@@ -439,7 +437,7 @@ $promise = Queue::all(3, $urls, function ($url) use ($browser) {
439437});
440438
441439try {
442- $responses = Block\ await($promise, $loop );
440+ $responses = await($promise);
443441 // responses successfully received
444442} catch (Exception $e) {
445443 // an error occured while performing the requests
@@ -450,6 +448,8 @@ Similarly, you can also wrap this in a function to provide a simple API and hide
450448all the async details from the outside:
451449
452450``` php
451+ use function React\Async\await;
452+
453453/**
454454 * Concurrently downloads all the given URIs
455455 *
@@ -465,12 +465,13 @@ function download(array $uris)
465465 return $browser->get($uri);
466466 });
467467
468- return Clue\React\Block\ await($promise, $loop );
468+ return await($promise);
469469}
470470```
471471
472- Please refer to [ clue/reactphp-block] ( https://github.com/clue/reactphp-block#readme )
473- for more details.
472+ This is made possible thanks to fibers available in PHP 8.1+ and our
473+ compatibility API that also works on all supported PHP versions.
474+ Please refer to [ reactphp/async] ( https://github.com/reactphp/async#readme ) for more details.
474475
475476> Keep in mind that returning an array of response messages means that the whole
476477 response body has to be kept in memory.
0 commit comments