|
34 | 34 | return $resource instanceof Tweet; |
35 | 35 | })->filter(function (Tweet $tweet) use ($profile) { |
36 | 36 | return $tweet->user()->idStr() === $profile->idStr(); |
37 | | - })->subscribeCallback(function (Tweet $tweet) use ($profile, $argv, $emojis) { |
38 | | - echo '------------------', PHP_EOL; |
39 | | - echo $tweet->text(), PHP_EOL; |
40 | | - echo '------------------', PHP_EOL; |
41 | | - $profile = $profile->withName(sprintf( |
42 | | - $argv[1], |
43 | | - $emojis[random_int(0, count($emojis) - 1)] |
44 | | - )); |
45 | | - $profile->putProfile()->done(function (ProfileInterface $newProfile) use ($profile) { |
46 | | - $profile = $newProfile; |
47 | | - resource_pretty_print($profile); |
48 | | - }); |
49 | | - }); |
| 37 | + })->subscribeCallback( |
| 38 | + function (Tweet $tweet) use ($profile, $argv, $emojis) { |
| 39 | + echo '------------------', PHP_EOL; |
| 40 | + echo $tweet->text(), PHP_EOL; |
| 41 | + echo '------------------', PHP_EOL; |
| 42 | + $profile = $profile->withName(sprintf( |
| 43 | + $argv[1], |
| 44 | + $emojis[random_int(0, count($emojis) - 1)] |
| 45 | + )); |
| 46 | + $profile->putProfile()->done(function (ProfileInterface $newProfile) use ($profile) { |
| 47 | + $profile = $newProfile; |
| 48 | + resource_pretty_print($profile); |
| 49 | + }); |
| 50 | + }, |
| 51 | + function ($e) { |
| 52 | + echo (string)$e; |
| 53 | + }, |
| 54 | + function () { |
| 55 | + echo PHP_EOL; |
| 56 | + echo '------------------', PHP_EOL; |
| 57 | + echo 'Completed streaming', PHP_EOL; |
| 58 | + echo '------------------', PHP_EOL; |
| 59 | + } |
| 60 | + ); |
50 | 61 | }); |
51 | 62 |
|
52 | 63 | $loop->run(); |
0 commit comments