Skip to content

Commit 0045d54

Browse files
authored
Merge pull request #196 from mbonneau/event-loop-update
Forward compatibility with react/event-loop 1.0 and 0.5 while still support 0.4
2 parents e44b2ae + c3d223a commit 0045d54

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"satooshi/php-coveralls": "~1.0",
2828
"phpunit/phpcov": "^3.1",
2929
"phpunit/phpunit": "^5.7",
30-
"react/event-loop": "^0.4.2"
30+
"react/event-loop": "^1.0 || ^0.5 || ^0.4.2"
3131
},
3232
"suggest": {
3333
"react/event-loop": "Used for scheduling async operations"

demo/subscribeOn/subscribeOn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
// Change scheduler for here
1919
$timer = $loop->addTimer(0.001, $handler);
2020

21-
return new CallbackDisposable(function () use ($timer) {
21+
return new CallbackDisposable(function () use ($loop, $timer) {
2222
// And change scheduler for here
2323
if ($timer) {
24-
$timer->cancel();
24+
$loop->cancelTimer($timer);
2525
}
2626
});
2727
});

src/Scheduler/EventLoopScheduler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function __construct($timerCallableOrLoop)
2929
$this->delayCallback = $timerCallableOrLoop instanceof LoopInterface ?
3030
function ($ms, $callable) use ($timerCallableOrLoop) {
3131
$timer = $timerCallableOrLoop->addTimer($ms / 1000, $callable);
32-
return new CallbackDisposable(function () use ($timer) {
33-
$timer->cancel();
32+
return new CallbackDisposable(function () use ($timer, $timerCallableOrLoop) {
33+
$timerCallableOrLoop->cancelTimer($timer);
3434
});
3535
} :
3636
$timerCallableOrLoop;

test/Rx/Scheduler/EventLoopSchedulerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers()
147147
$timersExecuted++;
148148
$action();
149149
});
150-
return new CallbackDisposable(function () use ($timer) {
151-
$timer->cancel();
150+
return new CallbackDisposable(function () use ($loop, $timer) {
151+
$loop->cancelTimer($timer);
152152
});
153153
});
154154

@@ -176,8 +176,8 @@ public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers(
176176
$timersExecuted++;
177177
$action();
178178
});
179-
return new CallbackDisposable(function () use ($timer) {
180-
$timer->cancel();
179+
return new CallbackDisposable(function () use ($loop, $timer) {
180+
$loop->cancelTimer($timer);
181181
});
182182
});
183183

@@ -206,8 +206,8 @@ public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDi
206206
$timersExecuted++;
207207
$action();
208208
});
209-
return new CallbackDisposable(function () use ($timer) {
210-
$timer->cancel();
209+
return new CallbackDisposable(function () use ($loop, $timer) {
210+
$loop->cancelTimer($timer);
211211
});
212212
});
213213

0 commit comments

Comments
 (0)