Skip to content

Instantly share code, notes, and snippets.

@clue
Created July 3, 2015 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clue/64a698e0ceba8451ac41 to your computer and use it in GitHub Desktop.
Save clue/64a698e0ceba8451ac41 to your computer and use it in GitHub Desktop.
React\Promise\uncancellable()
$cancellable = new Promise(function () { }, function ($resolve, $reject) { $reject(); });
$uncancellable = uncancellable($cancellable);
assertPending($cancellable);
assertPending($uncancellable);
// this is a NO-OP
$uncancellable->cancel();
assertPending($cancellable);
assertPending($uncancellable);
// this *still* works
$cancellable->cancel();
assertSettled($cancellable);
assertSettled($uncancellable);
function uncancellable(ExtendedPromiseInterface $promise)
{
return new Promise(function ($resolve, $reject) use ($promise) {
$promise->done($resolve, $reject);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment