thesebas/promise-async-await
Composer 安装命令:
composer require thesebas/promise-async-await
包简介
async-await emulation on generator+yield
README 文档
README
ReactPHP async-await emulator with generator and yield
Instalation
composer require thesebas/promise-async-await
Usage
It makes possible writing
asyncRun(function ($init) { $res = yield asyncFunc($init); $res2 = yield all([asyncFunc($res + 1), asyncFunc($res + 1)]); $res3 = yield race([asyncFunc($res * 2), asyncFunc($res2 / 2)]); return "wow" . $init . $res . $res2 . $res3; }, 0.1)->then(function ($result) { // ... $result is eq "wow".$init.$res.$res2.$res3; });
instead of
$init = 0.1; asyncFunc($init)->then(function ($res) { return all([asyncFunc($res + 1), asyncFunc($res + 1)]); })->then(function ($res2) { return yield race([asyncFunc(/* $res? */), asyncFunc($res2 / 2)]); })->then(function ($res3) { return "wow" ./* $init? */ /* $res?*/ /* $res2?*/ $res3 })->then(function ($result) { // ... $result is eq "wow".$res3; });
For more see spec
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-31