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.
Tags public mixed FULFILLED = 'fulfilled'
PENDING public mixed PENDING = 'pending'
REJECTED public mixed REJECTED = 'rejected'
cancel()
Cancels the promise if possible.
public cancel() : void
Tags
Get the state of the promise ("pending", "rejected", or "fulfilled").
public getState() : string
The three states can be checked against the constants defined on PromiseInterface: PENDING, FULFILLED, and REJECTED.
Return valuesstring otherwise()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.
public otherwise(callable $onRejected) : PromiseInterface
Parameters
Invoked when the promise is rejected.
Reject the promise with the given reason.
public reject(mixed $reason) : void
Parameters
if the promise is already resolved.
Resolve the promise with the given value.
public resolve(mixed $value) : void
Parameters
if the promise is already resolved.
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 $onFulfilled = null ][, callable $onRejected = null ]) : PromiseInterface
Parameters
Invoked when the promise fulfills.
Invoked when the promise is rejected.
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.
Parametersif the promise has no wait function or if the promise does not settle after waiting.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4