Skip to content

Commit

Permalink
Added example to README.md and touched up url_list.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonneau committed Apr 19, 2018
1 parent d09f327 commit da2b469
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,27 @@ It bootstraps a swoole scheduler for you, so you can do things like:

```

## Use with other Swoole modules

A small number of Swoole modules have helper Rx wrappers in this library.
You can use these to combine into more complex examples:
```php

// this example uses the rx/operator-extras package for `cut`

$file = \Rx\Swoole\Async::read(__DIR__ . '/url_list.txt');

$urlInfo = $file
->cut("\n")
->flatMap(function ($url) {
return \Rx\Swoole\Http::get($url)
->map(function ($content) use ($url) {
return $url . " is " . strlen($content) . " bytes.\n";
});
});

$urlInfo->subscribe(function ($info) {
echo $info;
});
```

6 changes: 3 additions & 3 deletions examples/url_list.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
https://www.google.com:80/
https://www.facebook.com:80/
https://www.microsoft.com:80/
https://www.google.com/
https://www.facebook.com/
https://www.microsoft.com/

0 comments on commit da2b469

Please sign in to comment.