Skip to content

Commit e1c80e8

Browse files
committed
Backport CancellablePromiseInterface to Promise v1 API
1 parent 44027fb commit e1c80e8

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Table of Contents
3737
* [When::reject()](#whenreject)
3838
* [When::lazy()](#whenlazy)
3939
* [Promisor](#promisor)
40+
* [CancellablePromiseInterface](#cancellablepromiseinterface)
41+
* [CancellablePromiseInterface::cancel()](#cancellablepromiseinterfacecancel)
4042
4. [Examples](#examples)
4143
* [How to use Deferred](#how-to-use-deferred)
4244
* [How Promise forwarding works](#how-promise-forwarding-works)
@@ -484,6 +486,24 @@ The `React\Promise\PromisorInterface` provides a common interface for objects
484486
that provide a promise. `React\Promise\Deferred` implements it, but since it
485487
is part of the public API anyone can implement it.
486488

489+
### CancellablePromiseInterface
490+
491+
A cancellable promise provides a mechanism for consumers to notify the creator
492+
of the promise that they are not longer interested in the result of an
493+
operation.
494+
495+
#### CancellablePromiseInterface::cancel()
496+
497+
``` php
498+
$promise->cancel();
499+
```
500+
501+
The `cancel()` method notifies the creator of the promise that there is no
502+
further interest in the results of the operation.
503+
504+
Once a promise is settled (either resolved or rejected), calling `cancel()` on
505+
a promise has no effect.
506+
487507
Examples
488508
--------
489509

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace React\Promise;
4+
5+
interface CancellablePromiseInterface extends PromiseInterface
6+
{
7+
/**
8+
* @return void
9+
*/
10+
public function cancel();
11+
}

0 commit comments

Comments
 (0)