razshare / react-php-yielder
一个简单的库,可以将生成器转换为 ReactPhp 的 PromiseInterfaces。
1.0.0
2021-10-14 08:46 UTC
Requires
- php: >=8.0
- react/event-loop: 1.2.0
- react/promise: 2.8.0
Requires (Dev)
- react/http: 1.5.0
- react/promise-stream: 1.2.0
- react/stream: 1.2.0
This package is auto-updated.
Last update: 2024-09-14 15:11:23 UTC
README
此库提供了一个流畅的 API,以便在 ReactPhp 事件循环中处理承诺和生成器。
\Razshare\ReactPhp\Yielder\Yielder::run(function(){ $result = yield new \React\Promise\Promise(function($r){ $r("hello world"); }); echo $result.PHP_EOL; });
这是一个简单的代码片段,从承诺中简单地打印 "hello world"。
这可能看起来没有太大区别,但当你考虑到为了保持应用程序顺利运行所需的异步操作数量时,这种简单的语法改进可以成为一种令人耳目一新且更方便处理承诺的方法。
入门
composer require razshare/react-php-yielder