32 function all(array $promises) {
39 foreach ($promises as $promiseIndex => $subPromise) {
42 function(
$result) use ($promiseIndex, &$completeResult, &$successCount,
$success, $promises) {
43 $completeResult[$promiseIndex] =
$result;
45 if ($successCount === count($promises)) {
51 function($reason) use ($fail) {
71 function race(array $promises) {
86 function($reason) use ($fail, &$alreadyDone) {
An implementation of the Promise pattern.
$promise
This example shows demonstrates the Promise api.
resolve($value)
Returns a Promise that resolves with the given value.
static all(array $promises)
Deprecated.
reject($reason=null)
Marks this promise as rejected, and set it's rejection reason.
race(array $promises)
The race function returns a promise that resolves or rejects as soon as one of the promises in the ar...
error(callable $onRejected)
Alias for 'otherwise'.