Promise
Table of Contents
- all() : Promise
- This function takes an array of Promises, and returns a Promise that resolves when all of the given arguments have resolved.
- race() : Promise
- The race function returns a promise that resolves or rejects as soon as one of the promises in the argument resolves or rejects.
- resolve() : Promise
- Returns a Promise that resolves with the given value.
- reject() : Promise
- Returns a Promise that will reject with the given reason.
Functions
all()
This function takes an array of Promises, and returns a Promise that resolves when all of the given arguments have resolved.
all(array<string|int, Promise> $promises) : Promise
The returned Promise will resolve with a value that's an array of all the values the given promises have been resolved with.
This array will be in the exact same order as the array of input promises.
If any of the given Promises fails, the returned promise will immediately fail with the first Promise that fails, and its reason.
Parameters
- $promises : array<string|int, Promise>
Return values
Promise —race()
The race function returns a promise that resolves or rejects as soon as one of the promises in the argument resolves or rejects.
race(array<string|int, Promise> $promises) : Promise
The returned promise will resolve or reject with the value or reason of that first promise.
Parameters
- $promises : array<string|int, Promise>
Return values
Promise —resolve()
Returns a Promise that resolves with the given value.
resolve(mixed $value) : Promise
If the value is a promise, the returned promise will attach itself to that promise and eventually get the same state as the followed promise.
Parameters
- $value : mixed
Return values
Promise —reject()
Returns a Promise that will reject with the given reason.
reject(Throwable $reason) : Promise
Parameters
- $reason : Throwable