icicleio/react-adapter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

icicleio/react-adapter

最新稳定版本:v0.4.0

Composer 安装命令:

composer require icicleio/react-adapter

包简介

Adapts the event loop and promises of Icicle to interfaces compatible with components built for React.

README 文档

README

@icicleio on Twitter Build Status Coverage Status Semantic Version MIT License

This library facilitates interoperability between components built for React and Icicle. This library provides an adapter between the differing event loop and promise implementations of the two libraries.

Requirements
  • PHP 5.5+
Installation

The recommended way to install is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)

Run the following command to use this library in your project:

composer require icicleio/react-adapter

You can also manually edit composer.json to add this library as a project requirement.

// composer.json
{
    "require": {
        "icicleio/react-adapter": "^0.4"
    }
}

ReactLoop

Icicle\ReactAdapter\Loop\ReactLoop is as a direct replacement for the React event loop. It communicates with the active Icicle event loop to provide the same functionality. The class implements React\EventLoop\LoopInterface, so it can be used with any component that requires a React event loop.

use Icicle\ReactAdapter\Loop\ReactLoop;
use Predis\Async\Client;

// Create the loop adapter.
$loop = new ReactLoop();

// $loop can be used anywhere an instance of React\EventLoop\LoopInterface is required.
$client = new Client('tcp://127.0.0.1:6379', $loop);

ReactPromise

Icicle\ReactAdapter\Promise\ReactPromise creates a promise implementing React\Promise\ExtendedPromiseInterface and React\Promise\ExtendedPromiseInterface from an Icicle awaitable that implements Icicle\Awaitable\Awaitable. This allows awaitables created from Icicle to be used in any component requiring a React promise.

$iciclePromise = new \Icicle\Awaitable\Promise(function ($resolve, $reject) {
    // Resolver
});

$reactPromise = new \Icicle\ReactAdapter\Promise\ReactPromise($iciclePromise);

Awaitable\adapt()

The Icicle\Awaitable namespace defines a function adapt() that can transform any object with a then(callable $onFulfilled, callable $onRejected) method into an awaitable implementing Icicle\Awaitable\Awaitable. This function can be used to convert a React promise to an Icicle awaitable.

$reactPromise = new \React\Promise\Promise(function ($resolve, $reject) {
    // Resolver
});

$awaitable = \Icicle\Awaitable\adapt($reactPromise);

See the Awaitable API documentation for more information on Icicle\Awaitable\adapt().

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-10