Open Journal Systems  3.3.0
GuzzleHttp\Promise\Promise Class Reference
Inheritance diagram for GuzzleHttp\Promise\Promise:
GuzzleHttp\Promise\PromiseInterface

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

- Data Fields inherited from GuzzleHttp\Promise\PromiseInterface
const FULFILLED = 'fulfilled'
 
const PENDING = 'pending'
 
const REJECTED = 'rejected'
 

Detailed Description

Promises/A+ implementation that avoids recursion when possible.

https://promisesaplus.com/

Definition at line 9 of file guzzlehttp/promises/src/Promise.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Promise\Promise::__construct ( callable  $waitFn = null,
callable  $cancelFn = null 
)
Parameters
callable$waitFnFn that when invoked resolves the promise.
callable$cancelFnFn that when invoked cancels the promise.

Definition at line 22 of file guzzlehttp/promises/src/Promise.php.

Member Function Documentation

◆ cancel()

GuzzleHttp\Promise\Promise::cancel ( )

◆ getState()

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.

Returns
string

Implements GuzzleHttp\Promise\PromiseInterface.

Definition at line 80 of file guzzlehttp/promises/src/Promise.php.

◆ otherwise()

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.

Parameters
callable$onRejectedInvoked when the promise is rejected.
Returns
PromiseInterface

Implements GuzzleHttp\Promise\PromiseInterface.

Definition at line 55 of file guzzlehttp/promises/src/Promise.php.

References GuzzleHttp\Promise\Promise\then().

◆ reject()

GuzzleHttp\Promise\Promise::reject (   $reason)

Reject the promise with the given reason.

Parameters
mixed$reason
Exceptions

Implements GuzzleHttp\Promise\PromiseInterface.

Definition at line 116 of file guzzlehttp/promises/src/Promise.php.

Referenced by GuzzleHttp\Promise\Promise\cancel().

◆ resolve()

GuzzleHttp\Promise\Promise::resolve (   $value)

Resolve the promise with the given value.

Parameters
mixed$value
Exceptions

Implements GuzzleHttp\Promise\PromiseInterface.

Definition at line 111 of file guzzlehttp/promises/src/Promise.php.

◆ then()

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.

Parameters
callable$onFulfilledInvoked when the promise fulfills.
callable$onRejectedInvoked when the promise is rejected.
Returns
PromiseInterface

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().

◆ wait()

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.

Parameters
bool$unwrap
Returns
mixed
Exceptions

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().


The documentation for this class was generated from the following file: