Nextcloud PHP API (master)

IPromise

A wrapper around Guzzle's PromiseInterface

Tags
see
PromiseInterface
since
28.0.0

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
since
28.0.0

STATE_PENDING

public mixed STATE_PENDING = 'pending'
Tags
since
28.0.0

STATE_REJECTED

public mixed STATE_REJECTED = 'rejected'
Tags
since
28.0.0

Methods

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
since
28.0.0
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
since
28.0.0
Return values
IPromise

wait()

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
Tags
throws
LogicException

if the promise has no wait function or if the promise does not settle after waiting.

since
28.0.0

        
On this page

Search results