Skip to content

Cancellable promise - #20

Merged
cboden merged 8 commits into
masterfrom
cancellable-promise
Oct 15, 2014
Merged

cboden merged 8 commits into
masterfrom
cancellable-promise

Conversation

@jsor

@jsor jsor commented Oct 4, 2014

Copy link
Copy Markdown
Member

Added CancellablePromiseInterface implemented by all promises.

Note on the implementation:

The $canceller callback is responsible for rejecting the promise, there is no automatic rejection mechanism (See https://github.com/reactphp/promise/tree/cancellable-promise#promise-1).

The $canceller callback is invoked only, if cancel() is called either on the root promise or on all derived promises.

Called on root promise

$promise = getCancellablePromise();

$promise->cancel(); // Promise is cancelled.

Called on derived promises

$promise = getCancellablePromise();

$derived1 = $promise->then();
$derived2 = $promise->then();

$derived1->cancel(); // $promises is not cancelled
$derived2->cancel(); // $promises is cancelled

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants