Created
July 3, 2015 08:32
-
-
Save clue/64a698e0ceba8451ac41 to your computer and use it in GitHub Desktop.
React\Promise\uncancellable()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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