IPromise
in
A wrapper around Guzzle's PromiseInterface
Tags
Table of Contents
Constants
- STATE_FULFILLED = 'fulfilled'
- STATE_PENDING = 'pending'
- STATE_REJECTED = 'rejected'
Methods
- cancel() : void
- Cancels the promise if possible.
- getState() : self::STATE_*
- Get the state of the promise ("pending", "rejected", or "fulfilled").
- then() : IPromise
- Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.
- wait() : mixed
- Waits until the promise completes if possible.
Constants
STATE_FULFILLED
public
mixed
STATE_FULFILLED
= 'fulfilled'
Tags
STATE_PENDING
public
mixed
STATE_PENDING
= 'pending'
Tags
STATE_REJECTED
public
mixed
STATE_REJECTED
= 'rejected'
Tags
Methods
cancel()
Cancels the promise if possible.
public
cancel() : void
Tags
getState()
Get the state of the promise ("pending", "rejected", or "fulfilled").
public
getState() : self::STATE_*
The three states can be checked against the constants defined: STATE_PENDING, STATE_FULFILLED, and STATE_REJECTED.
Tags
Return values
self::STATE_*then()
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.
public
then([callable(IResponse): void|null $onFulfilled = null ][, callable(Exception): void|null $onRejected = null ]) : IPromise
Parameters
- $onFulfilled : callable(IResponse): void|null = null
-
Invoked when the promise fulfills. Gets an \OCP\Http\Client\IResponse passed in as argument
- $onRejected : callable(Exception): void|null = null
-
Invoked when the promise is rejected. Gets an \Exception passed in as argument
Tags
Return values
IPromisewait()
Waits until the promise completes if possible.
public
wait([bool $unwrap = true ]) : mixed
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
- $unwrap : bool = true