@@ -154,21 +154,20 @@ If this looks strange to you, you can also use the more traditional [blocking AP
154
154
155
155
As stated above, this library provides you a powerful, async API by default.
156
156
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:
161
160
162
161
``` php
163
- use Clue\ React\Block ;
162
+ use function React\Async\await ;
164
163
165
164
$client = new Clue\React\Docker\Client();
166
165
167
166
$promise = $client->imageInspect('busybox');
168
167
169
168
try {
170
- $results = Block\ await($promise, Loop::get() );
171
- // resporesults successfully received
169
+ $results = await($promise);
170
+ // response results successfully received
172
171
} catch (Exception $e) {
173
172
// an error occured while performing the request
174
173
}
@@ -177,15 +176,19 @@ try {
177
176
Similarly, you can also process multiple commands concurrently and await an array of results:
178
177
179
178
``` php
179
+ use function React\Async\await;
180
+
180
181
$promises = array(
181
182
$client->imageInspect('busybox'),
182
183
$client->imageInspect('ubuntu'),
183
184
);
184
185
185
- $inspections = Block\awaitAll( $promises, Loop::get( ));
186
+ $inspections = await(all( $promises));
186
187
```
187
188
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.
189
192
190
193
#### Command streaming
191
194
0 commit comments