2017 © Pedro Peláez
 

library guzzle-to-react-promise

Transform a Guzzle Promise to a React Promise

image

tickner/guzzle-to-react-promise

Transform a Guzzle Promise to a React Promise

  • Saturday, October 22, 2016
  • by tickner
  • Repository
  • 1 Watchers
  • 0 Stars
  • 97 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 169 % Grown

The README.md

tickner/guzzle-to-react-promise

A function that will allow you to easily convert a Guzzle Promise to a React Promise., (*1)

Install

composer require tickner/guzzle-to-react-promise, (*2)

Why?

React and Guzzle have different promise implementations and they do not interop very well. In a project using ReactPHP, you may need to work with Guzzle for things like async access to the AWS SDK. If this happens, you will find your promise chains break unexpectedly when a Guzzle request promise is returned., (*3)

Using the function that this package provides, you can transform that promise into the React promise that your application would prefer to use., (*4)

Example

<?php

use GuzzleHttp\Promise\Promise as GuzzlePromise;
use function Tickner\GuzzleToReactPromise\guzzleToReactPromise;

$guzzlePromise = new GuzzlePromise(); // or a guzzle http request

$reactPromise = guzzleToReactPromise($guzzlePromise);

$reactPromise
    ->then(
        function($fulfilledValue) {
            echo $fulfilledValue;
        }
    )
;

$guzzlePromise->resolve('the val');

When the Guzzle Promise TaskQueue runs, the Guzzle Promise is resolved, and your React promise will also resolve and echo the val., (*5)

A shorter alias function is available: g2rp, (*6)

Tests and Contributing

To contribute, clone the repository and install the composer dependencies., (*7)

composer install, (*8)

To test, run phpunit in the root dir., (*9)

vendor/bin/phpunit, (*10)

License

Released under the the terms of the MIT License., (*11)

The Versions

22/10 2016

dev-master

9999999-dev

Transform a Guzzle Promise to a React Promise

  Sources   Download

MIT

The Requires

 

The Development Requires

22/10 2016

v1.0.0

1.0.0.0

Transform a Guzzle Promise to a React Promise

  Sources   Download

MIT

The Requires

 

The Development Requires