@@ -176,20 +176,54 @@ Timer\resolve(1.5, $loop)->then(function ($time) {
176176});
177177```
178178
179+ #### Resolve cancellation
180+
181+ You can explicitly ` cancel() ` the resulting timer promise at any time:
182+
183+ ``` php
184+ $timer = Timer\resolve(2.0, $loop);
185+
186+ $timer->cancel();
187+ ```
188+
189+ This will abort the timer and * reject* with a ` RuntimeException ` .
190+
191+ > Note: If you're stuck on legacy versions (PHP 5.3), then the ` cancel() ` method
192+ is not available, as the Promise cancellation API is currently only available in
193+ [ react/promise v2.1.0] ( https://github.com/reactphp/promise )
194+ which in turn requires PHP 5.4 or up.
195+
179196### reject()
180197
181198The ` reject($time, LoopInterface $loop) ` function can be used to create a new Promise
182199which rejects in ` $time ` seconds with a ` TimeoutException ` .
183200
184201``` php
185202Timer\reject(2.0, $loop)->then(null, function (TimeoutException $e) {
186- echo '
203+ echo 'Rejected after ' . $e->getTimeout() . ' seconds ' . PHP_EOL;
187204});
188205```
189206
190207This function complements the [ ` resolve() ` ] ( #resolve ) function
191208and can be used as a basic building block for higher-level promise consumers.
192209
210+ #### Reject cancellation
211+
212+ You can explicitly ` cancel() ` the resulting timer promise at any time:
213+
214+ ``` php
215+ $timer = Timer\reject(2.0, $loop);
216+
217+ $timer->cancel();
218+ ```
219+
220+ This will abort the timer and * reject* with a ` RuntimeException ` .
221+
222+ > Note: If you're stuck on legacy versions (PHP 5.3), then the ` cancel() ` method
223+ is not available, as the Promise cancellation API is currently only available in
224+ [ react/promise v2.1.0] ( https://github.com/reactphp/promise )
225+ which in turn requires PHP 5.4 or up.
226+
193227### TimeoutException
194228
195229The ` TimeoutException ` extends PHP's built-in ` RuntimeException ` .
0 commit comments