Download the PHP package fyre/promise without Composer
On this page you can find all versions of the php package fyre/promise. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package promise
FyrePromise
FyrePromise is a free, open-source promise library for PHP.
It is a modern library, and features support for synchronous and asynchronous promises.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Async Promises
- Static Methods
Installation
Using Composer
In PHP:
Basic Usage
$callback
is a Closure.
The $callback
should be expressed in the following format:
Methods
Catch
Execute a callback if the Promise is rejected.
$onRejected
is a Closure that will execute when the Promise is rejected.
This method will return a new Promise.
Finally
Execute a callback when the Promise is settled.
$onFinally
is a Closure that will execute when the Promise has settled.
This method will return a new Promise.
Then
Execute a callback when the Promise is resolved.
$onFulfilled
is a Closure that will execute when the Promise is resolved.$onRejected
is a Closure that will execute when the Promise is rejected, and will default to null.
This method will return a new Promise.
Async Promises
The \Fyre\Promise\AsyncPromise
class extends the Promise class, while providing additional methods for handling asynchronous operations.
Cancel
Cancel the pending AsyncPromise.
$message
is a string representing the cancellation message.
A cancelled promise will reject with a Fyre\Promise\Exceptions\CancelledPromiseException
.
Wait
Wait for the AsyncPromise to settle.
Static Methods
Any
Wait for any promise to resolve.
$promises
is an iterable containing the promises or values to wait for.
This method will return a new Promise.
All
Wait for all promises to resolve.
$promises
is an iterable containing the promises or values to wait for.
This method will return a new Promise.
Await
Wait for a Promise to settle.
$promise
is the Promise to wait for.
Race
Wait for the first promise to resolve.
$promises
is an iterable containing the promises or values to wait for.
This method will return a new Promise.
Reject
Create a Promise that rejects.
$reason
is a Throwable representing the rejected reason, and will default to null.
Resolve
Create a Promise that resolves.
$value
is the resolved value, and will default to null.