Open Journal Systems
3.3.0
|
Public Member Functions | |
cancel () | |
getState () | |
otherwise (callable $onRejected) | |
reject ($reason) | |
resolve ($value) | |
then (callable $onFulfilled=null, callable $onRejected=null) | |
wait ($unwrap=true) | |
Data Fields | |
const | FULFILLED = 'fulfilled' |
const | PENDING = 'pending' |
const | REJECTED = 'rejected' |
A promise represents the eventual result of an asynchronous operation.
The primary way of interacting with a promise is through its then method, which registers callbacks to receive either a promise’s eventual value or the reason why the promise cannot be fulfilled.
Definition at line 13 of file PromiseInterface.php.
GuzzleHttp\Promise\PromiseInterface::cancel | ( | ) |
Cancels the promise if possible.
https://github.com/promises-aplus/cancellation-spec/issues/7
Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.
GuzzleHttp\Promise\PromiseInterface::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.
Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.
Referenced by GuzzleHttp\Promise\is_fulfilled(), GuzzleHttp\Promise\is_rejected(), GuzzleHttp\Promise\is_settled(), and GuzzleHttp\Promise\some().
GuzzleHttp\Promise\PromiseInterface::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. |
Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.
GuzzleHttp\Promise\PromiseInterface::reject | ( | $reason | ) |
Reject the promise with the given reason.
mixed | $reason |
Implemented in GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.
Referenced by GuzzleHttp\Promise\each_limit_all().
GuzzleHttp\Promise\PromiseInterface::resolve | ( | $value | ) |
Resolve the promise with the given value.
mixed | $value |
Implemented in GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\RejectedPromise, and GuzzleHttp\Promise\FulfilledPromise.
Referenced by GuzzleHttp\Promise\some().
GuzzleHttp\Promise\PromiseInterface::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. |
Implemented in GuzzleHttp\Promise\Coroutine, GuzzleHttp\Promise\Promise, GuzzleHttp\Promise\FulfilledPromise, and GuzzleHttp\Promise\RejectedPromise.
Referenced by Http\Adapter\Guzzle6\Promise\__construct().
GuzzleHttp\Promise\PromiseInterface::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 |
Implemented in GuzzleHttp\Promise\Coroutine, and GuzzleHttp\Promise\Promise.
Referenced by GuzzleHttp\Promise\inspect(), and GuzzleHttp\Promise\Promise\wait().
const GuzzleHttp\Promise\PromiseInterface::FULFILLED = 'fulfilled' |
Definition at line 16 of file PromiseInterface.php.
Referenced by GuzzleHttp\Promise\FulfilledPromise\getState(), GuzzleHttp\Promise\inspect(), GuzzleHttp\Promise\is_fulfilled(), and GuzzleHttp\Promise\settle().
const GuzzleHttp\Promise\PromiseInterface::PENDING = 'pending' |
Definition at line 15 of file PromiseInterface.php.
Referenced by GuzzleHttp\Promise\is_settled(), and GuzzleHttp\Promise\some().
const GuzzleHttp\Promise\PromiseInterface::REJECTED = 'rejected' |
Definition at line 17 of file PromiseInterface.php.
Referenced by GuzzleHttp\Promise\RejectedPromise\getState(), GuzzleHttp\Promise\inspect(), GuzzleHttp\Promise\is_rejected(), and GuzzleHttp\Promise\settle().