Skip to content

Commit 5163994

Browse files
committed
Ensure we all use the same event loop without changes needed
This change sets the event loop on `React\EventLoop\Loop` to `Revolt\EventLoop\Adapter\React\RevoltLoop` so that there are no changes needed anywhere to use a single event loop.
1 parent 8e32af5 commit 5163994

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"Revolt\\EventLoop\\Adapter\\React\\": "src"
2727
},
2828
"files": [
29+
"src/bootstrap.php",
2930
"etc/Factory.php"
3031
]
3132
},

examples/1-timers.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
// This example is adapted from reactphp/event-loop, but running on Revolt's event loop.
44
// https://github.com/reactphp/event-loop/blob/85a0b7c0e35a47387a61d2ba8a772a7855b6af86/examples/01-timers.php
55

6-
use Revolt\EventLoop\Adapter\React\RevoltLoop;
6+
use React\EventLoop\Loop;
77

88
require __DIR__ . '/../vendor/autoload.php';
99

10-
$loop = RevoltLoop::get();
10+
echo 'Running with the following event loop: ', \get_class(Loop::get()), PHP_EOL;
1111

12-
$loop->addTimer(0.8, function () {
12+
Loop::addTimer(0.8, function () {
1313
echo 'world!' . PHP_EOL;
1414
});
1515

16-
$loop->addTimer(0.3, function () {
16+
Loop::addTimer(0.3, function () {
1717
echo 'hello ';
1818
});
1919

20-
$loop->run();
20+
Loop::run();

src/bootstrap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use React\EventLoop\Loop;
4+
use Revolt\EventLoop\Adapter\React\RevoltLoop;
5+
6+
/**
7+
* @psalm-suppress InternalMethod
8+
*/
9+
Loop::set(RevoltLoop::get());

0 commit comments

Comments
 (0)