Skip to content

Commit c9c72e9

Browse files
jsorclue
authored andcommitted
Documentation for Promise v2.2+ API
1 parent 8d2c883 commit c9c72e9

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,26 @@ Timer\timeout($promise, 10.0, $loop)->then(
5757
} else {
5858
// the input operation has failed due to some other error
5959
}
60-
throw $error;
6160
}
6261
);
6362
```
6463

64+
Or if you're using [react/promise v2.2.0](https://github.com/reactphp/promise) or up:
65+
66+
```php
67+
Timer\timeout($promise, 10.0, $loop)
68+
->then(function ($value) {
69+
// the operation finished within 10.0 seconds
70+
})
71+
->otherwise(function (Timer\TimeoutException $error) {
72+
// the operation has failed due to a timeout
73+
})
74+
->otherwise(function ($error) {
75+
// the input operation has failed due to some other error
76+
})
77+
;
78+
```
79+
6580
#### Timeout cancellation
6681

6782
As discussed above, the [`timeout()`](#timeout) function will *cancel* the

0 commit comments

Comments
 (0)