File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,41 @@ The recommended way to install react/async is [through composer](http://getcompo
2020
2121## Example
2222
23+ ``` php
24+ <?php
2325
26+ $loop = React\EventLoop\Factory::create();
27+
28+ React\Async\Util::parallel(
29+ array(
30+ function ($callback, $errback) use ($loop) {
31+ $loop->addTimer(1, function () use ($callback) {
32+ $callback('Slept for a whole second');
33+ });
34+ },
35+ function ($callback, $errback) use ($loop) {
36+ $loop->addTimer(1, function () use ($callback) {
37+ $callback('Slept for another whole second');
38+ });
39+ },
40+ function ($callback, $errback) use ($loop) {
41+ $loop->addTimer(1, function () use ($callback) {
42+ $callback('Slept for yet another whole second');
43+ });
44+ },
45+ ),
46+ function (array $results) {
47+ foreach ($results as $result) {
48+ var_dump($result);
49+ }
50+ },
51+ function (\Exception $e) {
52+ throw $e;
53+ }
54+ );
55+
56+ $loop->run();
57+ ```
2458
2559## Tests
2660
You can’t perform that action at this time.
0 commit comments