2017 © Pedro Peláez
 

library react-settle-promise

settle function for react-promise

image

cubetools/react-settle-promise

settle function for react-promise

  • Tuesday, November 7, 2017
  • by SimonHeimberg
  • Repository
  • 6 Watchers
  • 3 Stars
  • 288 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 27 % Grown

The README.md

React Settle Promise

Settle function for React\Promise., (*1)

Usage

use CubeTools\React\SettlePromise;

$promises = [
    React\Promise\resolve('foo'),
    React\Promise\reject(new \Exception()),
    'bar'
];

SettlePromise\settle($promises)->then(function(array $states) {
    foreach($states as $state) {
        if (SettlePromise\FULFILLED === $state['state']) {
            $promiseValue = $state['value'];
            ...
        } else { // SettlePromise\REJECTED
            $failureReason = $state['reason'];
            ...
        }
    }
});
use CubeTools\React\SettlePromise;
use Clue\React\Block;

$loop = \React\EventLoop\Factory::create();

foreach(Block\await(SettlePromise\settleWithTimeout($promises, 5, $loop), $loop) {
    if (SettlePromise\FULFILLED === $state['state']) {
        $promiseValue = $state['value'];
        ...
    } else { // SettlePromise\REJECTED
        $failureReason = $state['reason'];
        ...
    }
}

To replace the constants, subclass \CubeTools\React\SettlePromise\SettlePromise and define the class constants FULFILLED and REJECTED. Then use the class functions like YourClass::settle(...)., (*2)

Installation

Step 1: Download the Package

Open a command console, enter your project directory and execute the following command to download the latest stable version of this package:, (*3)

$ composer require cubetools/react-settle-promise

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*4)

The Versions

07/11 2017

dev-development

dev-development

settle function for react-promise

  Sources   Download

MIT

The Requires

 

The Development Requires

07/11 2017

dev-settleBoolean

dev-settleBoolean

settle function for react-promise

  Sources   Download

MIT

The Requires

 

The Development Requires

29/09 2017

dev-master

9999999-dev

settle function for react-promise

  Sources   Download

MIT

The Requires

 

The Development Requires

29/09 2017

0.1.0

0.1.0.0

settle function for react-promise

  Sources   Download

MIT

The Requires

 

The Development Requires