Skip to content

Commit 3c565e7

Browse files
committed
Added simple usage example
1 parent 30a33ee commit 3c565e7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ To install via [Composer](http://getcomposer.org/), use the command below, it wi
1717
composer require wyrihaximus/react-child-process-promise-closure
1818
```
1919

20+
## Usage ##
21+
22+
Usage is simple, just pass the function the event loop and a closure that returns an array as result or throws a `Throwable` on errors and it will run in a freshly spawned child process.
23+
24+
```php
25+
use function WyriHaximus\React\childProcessPromiseClosure;
26+
27+
childProcessPromiseClosure($loop, function () {
28+
return ['message' => 'The closure MUST always return an array'];
29+
})->done(function ($time) {
30+
echo $time['message'], PHP_EOL;
31+
});
32+
33+
```
34+
2035
## Examples ##
2136

2237
For examples see the [examples](https://github.com/WyriHaximus/reactphp-child-process-promise-closure/tree/master/examples) directory

0 commit comments

Comments
 (0)