Open Journal Systems  3.3.0
Http\Promise\Promise Interface Reference
Inheritance diagram for Http\Promise\Promise:
Http\Adapter\Guzzle6\Promise Http\Client\Promise\HttpFulfilledPromise Http\Client\Promise\HttpRejectedPromise Http\Promise\FulfilledPromise Http\Promise\RejectedPromise

Public Member Functions

 getState ()
 
 then (callable $onFulfilled=null, callable $onRejected=null)
 
 wait ($unwrap=true)
 

Data Fields

const FULFILLED = 'fulfilled'
 
const PENDING = 'pending'
 
const REJECTED = 'rejected'
 

Detailed Description

Promise represents a value that may not be available yet, but will be resolved at some point in future. It acts like a proxy to the actual value.

This interface is an extension of the promises/a+ specification.

See also
https://promisesaplus.com/
Author
Joel Wurtz joel..nosp@m.wurt.nosp@m.z@gma.nosp@m.il.c.nosp@m.om
Márk Sági-Kazár mark..nosp@m.sagi.nosp@m.kazar.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition at line 16 of file php-http/promise/src/Promise.php.

Member Function Documentation

◆ getState()

Http\Promise\Promise::getState ( )

Returns the state of the promise, one of PENDING, FULFILLED or REJECTED.

Returns
string

Implemented in Http\Adapter\Guzzle6\Promise, Http\Promise\FulfilledPromise, Http\Promise\RejectedPromise, Http\Client\Promise\HttpFulfilledPromise, and Http\Client\Promise\HttpRejectedPromise.

◆ then()

Http\Promise\Promise::then ( callable  $onFulfilled = null,
callable  $onRejected = null 
)

Adds behavior for when the promise is resolved or rejected (response will be available, or error happens).

If you do not care about one of the cases, you can set the corresponding callable to null The callback will be called when the value arrived and never more than once.

Parameters
callable$onFulfilledCalled when a response will be available.
callable$onRejectedCalled when an exception occurs.
Returns
Promise A new resolved promise with value of the executed callback (onFulfilled / onRejected).

Implemented in Http\Adapter\Guzzle6\Promise, Http\Promise\FulfilledPromise, Http\Promise\RejectedPromise, Http\Client\Promise\HttpFulfilledPromise, and Http\Client\Promise\HttpRejectedPromise.

◆ wait()

Http\Promise\Promise::wait (   $unwrap = true)

Wait for the promise to be fulfilled or rejected.

When this method returns, the request has been resolved and if callables have been specified, the appropriate one has terminated.

When $unwrap is true (the default), the response is returned, or the exception thrown on failure. Otherwise, nothing is returned or thrown.

Parameters
bool$unwrapWhether to return resolved value / throw reason or not
Returns
mixed Resolved value, null if $unwrap is set to false
Exceptions

Implemented in Http\Adapter\Guzzle6\Promise, Http\Promise\FulfilledPromise, Http\Promise\RejectedPromise, Http\Client\Promise\HttpFulfilledPromise, and Http\Client\Promise\HttpRejectedPromise.

Field Documentation

◆ FULFILLED

const Http\Promise\Promise::FULFILLED = 'fulfilled'

◆ PENDING

const Http\Promise\Promise::PENDING = 'pending'

Promise has not been fulfilled or rejected.

Definition at line 21 of file php-http/promise/src/Promise.php.

Referenced by Http\Adapter\Guzzle6\Promise\__construct().

◆ REJECTED

const Http\Promise\Promise::REJECTED = 'rejected'

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