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:
80
80
``` php
81
81
Loop::addTimer(0.5, React\Async\async(function() {
82
82
echo 'a';
83
- React\async \await(React\Promise\Timer\sleep(1.0));
83
+ React\Async \await(React\Promise\Timer\sleep(1.0));
84
84
echo 'c';
85
85
}));
86
86
87
- Loop::addTimer(1.0, fn() => echo 'b');
87
+ Loop::addTimer(1.0, function() {
88
+ echo 'b';
89
+ });
88
90
89
91
// prints "a" at t=0.5s
90
92
// prints "b" at t=1.0s
@@ -104,7 +106,9 @@ Loop::addTimer(0.5, React\Async\async(function() {
104
106
echo 'c';
105
107
}));
106
108
107
- Loop::addTimer(1.0, fn() => echo 'b');
109
+ Loop::addTimer(1.0, function() {
110
+ echo 'b';
111
+ });
108
112
109
113
// prints "a" at t=0.5s
110
114
// prints "c" at t=1.5s: Correct timing, but wrong order
@@ -249,11 +253,13 @@ outside this function can be executed asynchronously without blocking:
249
253
``` php
250
254
Loop::addTimer(0.5, React\Async\async(function() {
251
255
echo 'a';
252
- React\async \await(React\Promise\Timer\sleep(1.0));
256
+ React\Async \await(React\Promise\Timer\sleep(1.0));
253
257
echo 'c';
254
258
}));
255
259
256
- Loop::addTimer(1.0, fn() => echo 'b');
260
+ Loop::addTimer(1.0, function() {
261
+ echo 'b';
262
+ });
257
263
258
264
// prints "a" at t=0.5s
259
265
// prints "b" at t=1.0s
Original file line number Diff line number Diff line change 21
21
* ```php
22
22
* Loop::addTimer(0.5, React\Async\async(function() {
23
23
* echo 'a';
24
- * React\async \await(React\Promise\Timer\sleep(1.0));
24
+ * React\Async \await(React\Promise\Timer\sleep(1.0));
25
25
* echo 'c';
26
26
* }));
27
27
*
28
- * Loop::addTimer(1.0, fn() => echo 'b');
28
+ * Loop::addTimer(1.0, function() {
29
+ * echo 'b';
30
+ * });
29
31
*
30
32
* // prints "a" at t=0.5s
31
33
* // prints "b" at t=1.0s
45
47
* echo 'c';
46
48
* }));
47
49
*
48
- * Loop::addTimer(1.0, fn() => echo 'b');
50
+ * Loop::addTimer(1.0, function() {
51
+ * echo 'b';
52
+ * });
49
53
*
50
54
* // prints "a" at t=0.5s
51
55
* // prints "c" at t=1.5s: Correct timing, but wrong order
@@ -229,11 +233,13 @@ function async(callable $function): callable
229
233
* ```php
230
234
* Loop::addTimer(0.5, React\Async\async(function() {
231
235
* echo 'a';
232
- * React\async \await(React\Promise\Timer\sleep(1.0));
236
+ * React\Async \await(React\Promise\Timer\sleep(1.0));
233
237
* echo 'c';
234
238
* }));
235
239
*
236
- * Loop::addTimer(1.0, fn() => echo 'b');
240
+ * Loop::addTimer(1.0, function() {
241
+ * echo 'b';
242
+ * });
237
243
*
238
244
* // prints "a" at t=0.5s
239
245
* // prints "b" at t=1.0s
You can’t perform that action at this time.
0 commit comments