File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed
Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,13 @@ asynchronously without blocking:
8080``` php
8181Loop::addTimer(0.5, React\Async\async(function() {
8282 echo 'a';
83- React\async \await(React\Promise\Timer\sleep(1.0));
83+ React\Async \await(React\Promise\Timer\sleep(1.0));
8484 echo 'c';
8585}));
8686
87- Loop::addTimer(1.0, fn() => echo 'b');
87+ Loop::addTimer(1.0, function() {
88+ echo 'b';
89+ });
8890
8991// prints "a" at t=0.5s
9092// prints "b" at t=1.0s
@@ -104,7 +106,9 @@ Loop::addTimer(0.5, React\Async\async(function() {
104106 echo 'c';
105107}));
106108
107- Loop::addTimer(1.0, fn() => echo 'b');
109+ Loop::addTimer(1.0, function() {
110+ echo 'b';
111+ });
108112
109113// prints "a" at t=0.5s
110114// prints "c" at t=1.5s: Correct timing, but wrong order
@@ -249,11 +253,13 @@ outside this function can be executed asynchronously without blocking:
249253``` php
250254Loop::addTimer(0.5, React\Async\async(function() {
251255 echo 'a';
252- React\async \await(React\Promise\Timer\sleep(1.0));
256+ React\Async \await(React\Promise\Timer\sleep(1.0));
253257 echo 'c';
254258}));
255259
256- Loop::addTimer(1.0, fn() => echo 'b');
260+ Loop::addTimer(1.0, function() {
261+ echo 'b';
262+ });
257263
258264// prints "a" at t=0.5s
259265// prints "b" at t=1.0s
Original file line number Diff line number Diff line change 2121 * ```php
2222 * Loop::addTimer(0.5, React\Async\async(function() {
2323 * echo 'a';
24- * React\async \await(React\Promise\Timer\sleep(1.0));
24+ * React\Async \await(React\Promise\Timer\sleep(1.0));
2525 * echo 'c';
2626 * }));
2727 *
28- * Loop::addTimer(1.0, fn() => echo 'b');
28+ * Loop::addTimer(1.0, function() {
29+ * echo 'b';
30+ * });
2931 *
3032 * // prints "a" at t=0.5s
3133 * // prints "b" at t=1.0s
4547 * echo 'c';
4648 * }));
4749 *
48- * Loop::addTimer(1.0, fn() => echo 'b');
50+ * Loop::addTimer(1.0, function() {
51+ * echo 'b';
52+ * });
4953 *
5054 * // prints "a" at t=0.5s
5155 * // prints "c" at t=1.5s: Correct timing, but wrong order
@@ -229,11 +233,13 @@ function async(callable $function): callable
229233 * ```php
230234 * Loop::addTimer(0.5, React\Async\async(function() {
231235 * echo 'a';
232- * React\async \await(React\Promise\Timer\sleep(1.0));
236+ * React\Async \await(React\Promise\Timer\sleep(1.0));
233237 * echo 'c';
234238 * }));
235239 *
236- * Loop::addTimer(1.0, fn() => echo 'b');
240+ * Loop::addTimer(1.0, function() {
241+ * echo 'b';
242+ * });
237243 *
238244 * // prints "a" at t=0.5s
239245 * // prints "b" at t=1.0s
You can’t perform that action at this time.
0 commit comments