Skip to content

Commit 8da1cfd

Browse files
authored
Create README.md
1 parent 379138d commit 8da1cfd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# php-promise-async-await
2+
ReactPHP async-await emulator with generator and yield
3+
4+
5+
## Instalation
6+
7+
composer require thesebas/promise-async-await
8+
9+
## Usage
10+
It makes possible writing
11+
12+
asyncRun(function ($init) {
13+
$res = yield asyncFunc($init);
14+
$res2 = yield all([asyncFunc($res+1), asyncFunc($res+1)]);
15+
$res3 = yield race([asyncFunc($res*2), asyncFunc($res2/2)]);
16+
return "wow".$init.$res.$res2.$res3;
17+
}, 0.1)->then(function($result){
18+
// ... $result is eq "wow".$res.$res2.$res3;
19+
});
20+
21+
instead of
22+
23+
asyncFunc($init)->then(function($res){
24+
return all([asyncFunc($res+1), asyncFunc($res+1)]);
25+
})->then(function($res2){
26+
return yield race([asyncFunc(/* $res ?? */), asyncFunc($res2/2)]);
27+
})->then(function($res3){
28+
return "wow"./* $init ?? */ /* $res ??*/ /* $res2 ??*/ $res3
29+
})->then(function($result){
30+
// $result is eq "wow".$res3
31+
})
32+
33+
For more see `spec`

0 commit comments

Comments
 (0)