Skip to content

Commit 001dbef

Browse files
committed
Functional API instead of pseudo OOP
1 parent 30a6910 commit 001dbef

File tree

8 files changed

+199
-183
lines changed

8 files changed

+199
-183
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function blockingExample()
3535
{
3636
// use a unique event loop instance for all parallel operations
3737
$loop = React\EventLoop\Factory::create();
38-
$blocker = new Blocker();
3938

4039
// this example uses an HTTP client
4140
// this could be pretty much everything that binds to an event loop
@@ -46,23 +45,39 @@ function blockingExample()
4645
$request2 = $browser->get('http://www.google.co.uk/');
4746

4847
// keep the loop running (i.e. block) until the first response arrives
49-
$fasterResponse = $blocker->awaitAny(array($request1, $request2), $loop);
48+
$fasterResponse = Block\awaitAny(array($request1, $request2), $loop);
5049

5150
return $fasterResponse->getBody();
5251
}
5352
```
5453

5554
## Usage
5655

57-
### Blocker
56+
This lightweight library consists only of a few simple functions.
57+
All functions reside under the `Clue\React\Block` namespace.
5858

59-
The `Blocker` is responsible for orchestrating the
59+
The below examples assume you use an import statement similar to this:
60+
61+
```php
62+
use Clue\React\Block;
63+
64+
Block\await(…);
65+
```
66+
67+
Alternatively, you can also refer to them with their fully-qualified name:
68+
69+
```php
70+
\Clue\React\Block\await(…);
71+
```
72+
73+
### EventLoop
74+
75+
Each function is responsible for orchestrating the
6076
[`EventLoop`](https://github.com/reactphp/event-loop#usage)
6177
in order to make it run (block) until your conditions are fulfilled.
6278

6379
```php
6480
$loop = React\EventLoop\Factory::create();
65-
$blocker = new Blocker();
6681
```
6782

6883
#### sleep()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"autoload": {
14-
"psr-4": { "Clue\\React\\Block\\": "src/" }
14+
"files": [ "src/Blocker.php" ]
1515
},
1616
"require": {
1717
"php": ">=5.3",

0 commit comments

Comments
 (0)