Skip to content

Update example to new eventloop API #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ Once [installed](#install), you can use the following code to decorate a demo
function and avoid sending unneeded HTTP requests:

```php
$browser = new React\Http\Browser($loop);
<?php

require __DIR__ . '/vendor/autoload.php';

$browser = new React\Http\Browser();

$fetch = function (int $id) use ($browser) {
return $browser->get('http://httpbingo.org/status/' . $id)->then(function (ResponseInterface $response) {
return $browser->get(
'http://httpbingo.org/status/' . $id
)->then(function (Psr\Http\Message\ResponseInterface $response) {
return $response->getStatusCode();
});
}
Expand Down