Skip to content

Commit 135939e

Browse files
committed
Use reactphp/async instead of clue/reactphp-block
1 parent 847aab4 commit 135939e

File tree

5 files changed

+64
-61
lines changed

5 files changed

+64
-61
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
PHPUnit:
99
runs-on: ubuntu-20.04
10+
timeout-minutes: 5
1011
strategy:
1112
matrix:
1213
php:

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,20 @@ If this looks strange to you, you can also use the more traditional [blocking AP
154154

155155
As stated above, this library provides you a powerful, async API by default.
156156

157-
If, however, you want to integrate this into your traditional, blocking environment,
158-
you should look into also using [clue/reactphp-block](https://github.com/clue/reactphp-block).
159-
160-
The resulting blocking code could look something like this:
157+
You can also integrate this into your traditional, blocking environment by using
158+
[reactphp/async](https://github.com/reactphp/async). This allows you to simply
159+
await commands on the client like this:
161160

162161
```php
163-
use Clue\React\Block;
162+
use function React\Async\await;
164163

165164
$client = new Clue\React\Docker\Client();
166165

167166
$promise = $client->imageInspect('busybox');
168167

169168
try {
170-
$results = Block\await($promise, Loop::get());
171-
// resporesults successfully received
169+
$results = await($promise);
170+
// response results successfully received
172171
} catch (Exception $e) {
173172
// an error occured while performing the request
174173
}
@@ -177,15 +176,19 @@ try {
177176
Similarly, you can also process multiple commands concurrently and await an array of results:
178177

179178
```php
179+
use function React\Async\await;
180+
180181
$promises = array(
181182
$client->imageInspect('busybox'),
182183
$client->imageInspect('ubuntu'),
183184
);
184185

185-
$inspections = Block\awaitAll($promises, Loop::get());
186+
$inspections = await(all($promises));
186187
```
187188

188-
Please refer to [clue/reactphp-block](https://github.com/clue/reactphp-block#readme) for more details.
189+
This is made possible thanks to fibers available in PHP 8.1+ and our
190+
compatibility API that also works on all supported PHP versions.
191+
Please refer to [reactphp/async](https://github.com/reactphp/async#readme) for more details.
189192

190193
#### Command streaming
191194

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"rize/uri-template": "^0.3"
2929
},
3030
"require-dev": {
31-
"clue/block-react": "^1.5",
31+
"react/async": "^4 || ^3 || ^2",
3232
"clue/caret-notation": "^0.2",
3333
"clue/tar-react": "^0.2",
3434
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"

0 commit comments

Comments
 (0)