定制 tickner/guzzle-to-react-promise 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tickner/guzzle-to-react-promise

Composer 安装命令:

composer require tickner/guzzle-to-react-promise

包简介

Transform a Guzzle Promise to a React Promise

README 文档

README

A function that will allow you to easily convert a Guzzle Promise to a React Promise.

Install

composer require tickner/guzzle-to-react-promise

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.

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

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.

A shorter alias function is available: g2rp

Tests and Contributing

To contribute, clone the repository and install the composer dependencies.

composer install

To test, run phpunit in the root dir.

vendor/bin/phpunit

License

Released under the the terms of the MIT License.

统计信息

  • 总下载量: 3.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固