5
5
< meta http-equiv ="x-ua-compatible " content ="ie=edge ">
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1, shrink-to-fit=no ">
7
7
8
- < title > Async:
9
- Async Utilities - ReactPHP</ title >
8
+ < title > Async: Async Utilities - ReactPHP</ title >
10
9
11
10
< meta name ="description " content ="Async utilities and fibers for ReactPHP. ">
12
11
@@ -129,7 +128,7 @@ <h3 class="off-canvas-menu__section-header">Network Components</h3>
129
128
HTTP
130
129
131
130
< span class ="off-canvas-menu__version ">
132
- v1.6 .0
131
+ v1.7 .0
133
132
</ span >
134
133
</ a >
135
134
</ li >
@@ -221,8 +220,8 @@ <h3 class="off-canvas-menu__section-header">Legacy Components</h3>
221
220
< h1 > Async</ h1 >
222
221
223
222
224
- < p > < a href ="https://github.com/reactphp/async/actions "> < img src ="https://github.com/reactphp/async/workflows/CI/badge.svg " alt ="CI status " style ="max-width:100%; "> </ a >
225
- < a href ="https://packagist.org/packages/react/async " rel ="nofollow "> < img src ="https://camo.githubusercontent.com/3b14cc18b50d4f3ce0a5fac671667b6f4035fb79695b4acda1eba22ed3841f62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656163742f6173796e633f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374 " alt ="installs on Packagist " data-canonical-src ="https://img.shields.io/packagist/dt/react/async?color=blue&label=installs%20on%20Packagist " style ="max-width:100%; "> </ a > </ p >
223
+ < p > < a href ="https://github.com/reactphp/async/actions "> < img src ="https://github.com/reactphp/async/workflows/CI/badge.svg " alt ="CI status " style ="max-width: 100%; "> </ a >
224
+ < a href ="https://packagist.org/packages/react/async " rel ="nofollow "> < img src ="https://camo.githubusercontent.com/3b14cc18b50d4f3ce0a5fac671667b6f4035fb79695b4acda1eba22ed3841f62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656163742f6173796e633f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374 " alt ="installs on Packagist " data-canonical-src ="https://img.shields.io/packagist/dt/react/async?color=blue&label=installs%20on%20Packagist " style ="max-width: 100%; "> </ a > </ p >
226
225
< p > Async utilities and fibers for < a href ="https://reactphp.org/ " rel ="nofollow "> ReactPHP</ a > .</ p >
227
226
< p > This library allows you to manage async control flow. It provides a number of
228
227
combinators for < a href ="../promise/ "> Promise</ a > -based APIs.
@@ -250,8 +249,7 @@ <h1>Async</h1>
250
249
< li > < a href ="#tests "> Tests</ a > </ li >
251
250
< li > < a href ="#license "> License</ a > </ li >
252
251
</ ul >
253
- < h2 >
254
- < a id ="usage " class ="anchor " href ="#usage " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Usage</ h2 >
252
+ < h2 > < a id ="usage " class ="anchor " aria-hidden ="true " href ="#usage "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Usage</ h2 >
255
253
< p > This lightweight library consists only of a few simple functions.
256
254
All functions reside under the < code > React\Async</ code > namespace.</ p >
257
255
< p > The below examples refer to all functions with their fully-qualified names like this:</ p >
264
262
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-k "> use</ span > < span class ="pl-v "> React</ span > \< span class ="pl-v "> Async</ span > ;
265
263
266
264
< span class ="pl-en "> < span class ="pl-v "> Async</ span > \await</ span > (…);</ pre > </ div >
267
- < h3 >
268
- < a id ="async " class ="anchor " href ="#async " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > async()</ h3 >
265
+ < h3 > < a id ="async " class ="anchor " aria-hidden ="true " href ="#async "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > async()</ h3 >
269
266
< p > The < code > async(callable $function): callable</ code > function can be used to
270
267
return an async function for a function that uses < a href ="#await "> < code > await()</ code > </ a > internally.</ p >
271
268
< p > This function is specifically designed to complement the < a href ="#await "> < code > await()</ code > function</ a > .
406
403
407
404
< span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > promise</ span > ->< span class ="pl-en "> cancel</ span > ();
408
405
await(< span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > promise</ span > );</ pre > </ div >
409
- < h3 >
410
- < a id ="await " class ="anchor " href ="#await " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > await()</ h3 >
406
+ < h3 > < a id ="await " class ="anchor " aria-hidden ="true " href ="#await "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > await()</ h3 >
411
407
< p > The < code > await(PromiseInterface $promise): mixed</ code > function can be used to
412
408
block waiting for the given < code > $promise</ code > to be fulfilled.</ p >
413
409
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > result</ span > = < span class ="pl-en "> < span class ="pl-v "> React</ span > \< span class ="pl-v "> Async</ span > \await</ span > (< span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > promise</ span > );</ pre > </ div >
444
440
< span class ="pl-c "> // promise rejected with $e</ span >
445
441
< span class ="pl-k "> echo</ span > < span class ="pl-s "> 'Error: '</ span > . < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ->< span class ="pl-en "> getMessage</ span > ();
446
442
}</ pre > </ div >
447
- < h3 >
448
- < a id ="coroutine " class ="anchor " href ="#coroutine " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > coroutine()</ h3 >
443
+ < h3 > < a id ="coroutine " class ="anchor " aria-hidden ="true " href ="#coroutine "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > coroutine()</ h3 >
449
444
< p > The < code > coroutine(callable $function, mixed ...$args): PromiseInterface<mixed></ code > function can be used to
450
445
execute a Generator-based coroutine to "await" promises.</ p >
451
446
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-en "> < span class ="pl-v "> React</ span > \< span class ="pl-v "> Async</ span > \coroutine</ span > (< span class ="pl-k "> function</ span > () {
543
538
}, < span class ="pl-k "> function</ span > (< span class ="pl-smi "> < span class ="pl-smi "> Exception</ span > </ span > < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ) {
544
539
< span class ="pl-k "> echo</ span > < span class ="pl-s "> 'Error: '</ span > . < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ->< span class ="pl-en "> getMessage</ span > () . < span class ="pl-c1 "> PHP_EOL</ span > ;
545
540
});</ pre > </ div >
546
- < h3 >
547
- < a id ="parallel " class ="anchor " href ="#parallel " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > parallel()</ h3 >
541
+ < h3 > < a id ="parallel " class ="anchor " aria-hidden ="true " href ="#parallel "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > parallel()</ h3 >
548
542
< p > The < code > parallel(iterable<callable():PromiseInterface<mixed,Exception>> $tasks): PromiseInterface<array<mixed>,Exception></ code > function can be used
549
543
like this:</ p >
550
544
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-ent "> <?php</ span >
581
575
}, < span class ="pl-k "> function</ span > (< span class ="pl-smi "> < span class ="pl-smi "> Exception</ span > </ span > < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ) {
582
576
< span class ="pl-k "> echo</ span > < span class ="pl-s "> 'Error: '</ span > . < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ->< span class ="pl-en "> getMessage</ span > () . < span class ="pl-c1 "> PHP_EOL</ span > ;
583
577
});</ pre > </ div >
584
- < h3 >
585
- < a id ="series " class ="anchor " href ="#series " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > series()</ h3 >
578
+ < h3 > < a id ="series " class ="anchor " aria-hidden ="true " href ="#series "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > series()</ h3 >
586
579
< p > The < code > series(iterable<callable():PromiseInterface<mixed,Exception>> $tasks): PromiseInterface<array<mixed>,Exception></ code > function can be used
587
580
like this:</ p >
588
581
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-ent "> <?php</ span >
619
612
}, < span class ="pl-k "> function</ span > (< span class ="pl-smi "> < span class ="pl-smi "> Exception</ span > </ span > < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ) {
620
613
< span class ="pl-k "> echo</ span > < span class ="pl-s "> 'Error: '</ span > . < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ->< span class ="pl-en "> getMessage</ span > () . < span class ="pl-c1 "> PHP_EOL</ span > ;
621
614
});</ pre > </ div >
622
- < h3 >
623
- < a id ="waterfall " class ="anchor " href ="#waterfall " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > waterfall()</ h3 >
615
+ < h3 > < a id ="waterfall " class ="anchor " aria-hidden ="true " href ="#waterfall "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > waterfall()</ h3 >
624
616
< p > The < code > waterfall(iterable<callable(mixed=):PromiseInterface<mixed,Exception>> $tasks): PromiseInterface<mixed,Exception></ code > function can be used
625
617
like this:</ p >
626
618
< div class ="highlight highlight-text-html-php "> < pre > < span class ="pl-ent "> <?php</ span >
@@ -645,13 +637,11 @@ <h3>
645
637
}, < span class ="pl-k "> function</ span > (< span class ="pl-smi "> < span class ="pl-smi "> Exception</ span > </ span > < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ) {
646
638
< span class ="pl-k "> echo</ span > < span class ="pl-s "> 'Error: '</ span > . < span class ="pl-s1 "> < span class ="pl-c1 "> $</ span > e</ span > ->< span class ="pl-en "> getMessage</ span > () . < span class ="pl-c1 "> PHP_EOL</ span > ;
647
639
});</ pre > </ div >
648
- < h2 >
649
- < a id ="todo " class ="anchor " href ="#todo " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Todo</ h2 >
640
+ < h2 > < a id ="todo " class ="anchor " aria-hidden ="true " href ="#todo "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Todo</ h2 >
650
641
< ul >
651
642
< li > Implement queue()</ li >
652
643
</ ul >
653
- < h2 >
654
- < a id ="install " class ="anchor " href ="#install " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Install</ h2 >
644
+ < h2 > < a id ="install " class ="anchor " aria-hidden ="true " href ="#install "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Install</ h2 >
655
645
< p > The recommended way to install this library is < a href ="https://getcomposer.org/ " rel ="nofollow "> through Composer</ a > .
656
646
< a href ="https://getcomposer.org/doc/00-intro.md " rel ="nofollow "> New to Composer?</ a > </ p >
657
647
< p > This project follows < a href ="https://semver.org/ " rel ="nofollow "> SemVer</ a > .
@@ -669,15 +659,13 @@ <h2>
669
659
You may target multiple versions at the same time to support a wider range of
670
660
PHP versions like this:</ p >
671
661
< div class ="highlight highlight-source-shell "> < pre > composer require < span class ="pl-s "> < span class ="pl-pds "> "</ span > react/async:^4 || ^3 || ^2< span class ="pl-pds "> "</ span > </ span > </ pre > </ div >
672
- < h2 >
673
- < a id ="tests " class ="anchor " href ="#tests " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Tests</ h2 >
662
+ < h2 > < a id ="tests " class ="anchor " aria-hidden ="true " href ="#tests "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > Tests</ h2 >
674
663
< p > To run the test suite, you first need to clone this repo and then install all
675
664
dependencies < a href ="https://getcomposer.org/ " rel ="nofollow "> through Composer</ a > :</ p >
676
665
< div class ="highlight highlight-source-shell "> < pre > composer install</ pre > </ div >
677
666
< p > To run the test suite, go to the project root and run:</ p >
678
667
< div class ="highlight highlight-source-shell "> < pre > vendor/bin/phpunit</ pre > </ div >
679
- < h2 >
680
- < a id ="license " class ="anchor " href ="#license " aria-hidden ="true "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > License</ h2 >
668
+ < h2 > < a id ="license " class ="anchor " aria-hidden ="true " href ="#license "> < span aria-hidden ="true " class ="octicon octicon-link "> </ span > </ a > License</ h2 >
681
669
< p > MIT, see < a href ="license.html "> LICENSE file</ a > .</ p >
682
670
< p > This project is heavily influenced by < a href ="https://github.com/caolan/async "> async.js</ a > .</ p >
683
671
</ main >
@@ -750,12 +738,12 @@ <h3 class="component-info__subtitle">Contributors</h3>
750
738
< ul class ="component-info__contributors ">
751
739
< li >
752
740
< a href ="https://github.com/clue ">
753
- < img src ="https://avatars.githubusercontent.com/u/776829?v=4&s=40 " srcset ="https://avatars.githubusercontent.com/u/776829?v=4&s=80 2x " alt ="clue " title ="clue (45 contributions) ">
741
+ < img src ="https://avatars.githubusercontent.com/u/776829?v=4&s=40 " srcset ="https://avatars.githubusercontent.com/u/776829?v=4&s=80 2x " alt ="clue " title ="clue (47 contributions) ">
754
742
</ a >
755
743
</ li >
756
744
< li >
757
745
< a href ="https://github.com/WyriHaximus ">
758
- < img src ="https://avatars.githubusercontent.com/u/147145?v=4&s=40 " srcset ="https://avatars.githubusercontent.com/u/147145?v=4&s=80 2x " alt ="WyriHaximus " title ="WyriHaximus (30 contributions) ">
746
+ < img src ="https://avatars.githubusercontent.com/u/147145?v=4&s=40 " srcset ="https://avatars.githubusercontent.com/u/147145?v=4&s=80 2x " alt ="WyriHaximus " title ="WyriHaximus (31 contributions) ">
759
747
</ a >
760
748
</ li >
761
749
< li >
@@ -792,7 +780,7 @@ <h3 class="component-info__subtitle">Activity</h3>
792
780
< mask id ="reactphp-async-participation-sparkline " x ="0 " y ="0 " width ="320 " height ="40 " >
793
781
< polyline
794
782
transform ="translate(0, 40) scale(1,-1) "
795
- points ="0,1 6,1 12,1 18,1 24,1 30,1 36,1 42,1 48,1 54,1 60,1 66,1 72,4 78,1 84,22 90,1 96,4 102,1 108,15 114,2 120,1 126,1 132,2 138,4 144,1 150,2 156,1 162,1 168,3 174,1 180,7 186,6 192,1 198,4 204,1 210,2 216,2 222,1 228,1 234,1 240,1 246,1 252,1 258,1 264,1 270,1 276,3 282,4 288,2 294,3 300,3 306,3 "
783
+ points ="0,1 6,1 12,1 18,1 24,1 30,3 36,2 42,16 48,7 54,1 60,4 66,7 72,10 78,1 84,1 90,2 96,3 102,2 108,2 114,1 120,1 126,2 132,2 138,1 144,8 150,5 156,1 162,4 168,1 174,3 180,1 186,1 192,1 198,1 204,1 210,1 216,1 222,1 228,1 234,1 240,4 246,4 252,2 258,2 264,5 270,2 276,1 282,1 288,1 294,1 300,2 306,2 "
796
784
fill ="transparent "
797
785
stroke ="#40a977 "
798
786
stroke-width ="2 "
0 commit comments