esroyo/react-promise-settle

Returns a promise that is fulfilled when all of the provided promises have been fulfilled or rejected.

Maintainers

👁 esroyo

Package info

git.sr.ht/~esroyo/reactphp-promise-settle

pkg:composer/esroyo/react-promise-settle

Statistics

Installs: 27

Dependents: 1

Suggesters: 0

dev-master / 1.0.0.x-dev 2021-11-26 18:19 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 7aa0bde71b16ad08c3696b377961ecc61e885a8e

event-looppromisespromisereactphpsettle

This package is auto-updated.

Last update: 2026-06-27 04:45:34 UTC


README

👁 builds.sr.ht status
👁 Software License
👁 Total Downloads

Provides a settle() function missing from the official react/promise.

Installation

composer require esroyo/react-promise-settle

Usage

$promise = Esroyo\React\Promise\settle(array $promisesOrValues);

Returns a promise that is fullfilled when all the items in $promisesOrValues have been fulfilled or rejected.

The resolution value of the returned promise will be an state associative array containing a "state" key mapping to a valid promise state. If the state of the promise is "fulfilled", the array will contain a "value" key mapping to the fulfilled value of the promise. If the promise is rejected, the array will contain a "reason" key mapping to the rejection reason of the promise.

Example result (array keys should be according to $promisesOrValues input):

[
 ['state' => 'fulfilled', 'value' => 'Result of work'],
 ['state' => 'rejected', 'reason' => 'Timeout'],
 ...
]

Credits

This package is a reaccommodation of cubetools/react-settle-promise and the original idea, authored by @jsor and @SimonHeimberg.