Open Journal Systems
3.3.0
|
Public Member Functions | |
__construct (callable $waitFn=null, callable $cancelFn=null) | |
cancel () | |
getState () | |
otherwise (callable $onRejected) | |
reject ($reason) | |
resolve ($value) | |
then (callable $onFulfilled=null, callable $onRejected=null) | |
wait ($unwrap=true) | |
Additional Inherited Members | |
![]() | |
const | FULFILLED = 'fulfilled' |
const | PENDING = 'pending' |
const | REJECTED = 'rejected' |
Promises/A+ implementation that avoids recursion when possible.
Definition at line 9 of file guzzlehttp/promises/src/Promise.php.
GuzzleHttp\Promise\Promise::__construct | ( | callable | $waitFn = null , |
callable | $cancelFn = null |
||
) |
callable | $waitFn | Fn that when invoked resolves the promise. |
callable | $cancelFn | Fn that when invoked cancels the promise. |
Definition at line 22 of file guzzlehttp/promises/src/Promise.php.
GuzzleHttp\Promise\Promise::cancel | ( | ) |
Cancels the promise if possible.
https://github.com/promises-aplus/cancellation-spec/issues/7
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 85 of file guzzlehttp/promises/src/Promise.php.
References GuzzleHttp\Promise\Promise\reject().
GuzzleHttp\Promise\Promise::getState | ( | ) |
Get the state of the promise ("pending", "rejected", or "fulfilled").
The three states can be checked against the constants defined on PromiseInterface: PENDING, FULFILLED, and REJECTED.
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 80 of file guzzlehttp/promises/src/Promise.php.
GuzzleHttp\Promise\Promise::otherwise | ( | callable | $onRejected | ) |
Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.
callable | $onRejected | Invoked when the promise is rejected. |
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 55 of file guzzlehttp/promises/src/Promise.php.
References GuzzleHttp\Promise\Promise\then().
GuzzleHttp\Promise\Promise::reject | ( | $reason | ) |
Reject the promise with the given reason.
mixed | $reason |
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 116 of file guzzlehttp/promises/src/Promise.php.
Referenced by GuzzleHttp\Promise\Promise\cancel().
GuzzleHttp\Promise\Promise::resolve | ( | $value | ) |
Resolve the promise with the given value.
mixed | $value |
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 111 of file guzzlehttp/promises/src/Promise.php.
GuzzleHttp\Promise\Promise::then | ( | callable | $onFulfilled = null , |
callable | $onRejected = null |
||
) |
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.
callable | $onFulfilled | Invoked when the promise fulfills. |
callable | $onRejected | Invoked when the promise is rejected. |
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 30 of file guzzlehttp/promises/src/Promise.php.
References GuzzleHttp\Promise\promise_for(), and GuzzleHttp\Promise\rejection_for().
Referenced by GuzzleHttp\Promise\all(), GuzzleHttp\Promise\FulfilledPromise\otherwise(), GuzzleHttp\Promise\RejectedPromise\otherwise(), GuzzleHttp\Promise\Promise\otherwise(), GuzzleHttp\Promise\settle(), and GuzzleHttp\Promise\some().
GuzzleHttp\Promise\Promise::wait | ( | $unwrap = true | ) |
Waits until the promise completes if possible.
Pass $unwrap as true to unwrap the result of the promise, either returning the resolved value or throwing the rejected exception.
If the promise cannot be waited on, then the promise will be rejected.
bool | $unwrap |
Implements GuzzleHttp\Promise\PromiseInterface.
Definition at line 60 of file guzzlehttp/promises/src/Promise.php.
References GuzzleHttp\Promise\exception_for(), and GuzzleHttp\Promise\PromiseInterface\wait().