diff --git a/composer.json b/composer.json index 23ba69d3..02612e4f 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "satooshi/php-coveralls": "~1.0", "phpunit/phpcov": "^3.1", "phpunit/phpunit": "^5.7", - "react/event-loop": "^0.4.2" + "react/event-loop": "^1.0 || ^0.5 || ^0.4.2" }, "suggest": { "react/event-loop": "Used for scheduling async operations" diff --git a/demo/subscribeOn/subscribeOn.php b/demo/subscribeOn/subscribeOn.php index b45ba32e..c7c6f8e7 100644 --- a/demo/subscribeOn/subscribeOn.php +++ b/demo/subscribeOn/subscribeOn.php @@ -18,10 +18,10 @@ // Change scheduler for here $timer = $loop->addTimer(0.001, $handler); - return new CallbackDisposable(function () use ($timer) { + return new CallbackDisposable(function () use ($loop, $timer) { // And change scheduler for here if ($timer) { - $timer->cancel(); + $loop->cancelTimer($timer); } }); }); diff --git a/src/Scheduler/EventLoopScheduler.php b/src/Scheduler/EventLoopScheduler.php index 51b83e35..98059a1b 100644 --- a/src/Scheduler/EventLoopScheduler.php +++ b/src/Scheduler/EventLoopScheduler.php @@ -29,8 +29,8 @@ public function __construct($timerCallableOrLoop) $this->delayCallback = $timerCallableOrLoop instanceof LoopInterface ? function ($ms, $callable) use ($timerCallableOrLoop) { $timer = $timerCallableOrLoop->addTimer($ms / 1000, $callable); - return new CallbackDisposable(function () use ($timer) { - $timer->cancel(); + return new CallbackDisposable(function () use ($timer, $timerCallableOrLoop) { + $timerCallableOrLoop->cancelTimer($timer); }); } : $timerCallableOrLoop; diff --git a/test/Rx/Scheduler/EventLoopSchedulerTest.php b/test/Rx/Scheduler/EventLoopSchedulerTest.php index a342ac57..2311ab2c 100644 --- a/test/Rx/Scheduler/EventLoopSchedulerTest.php +++ b/test/Rx/Scheduler/EventLoopSchedulerTest.php @@ -147,8 +147,8 @@ public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers() $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($timer) { - $timer->cancel(); + return new CallbackDisposable(function () use ($loop, $timer) { + $loop->cancelTimer($timer); }); }); @@ -176,8 +176,8 @@ public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers( $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($timer) { - $timer->cancel(); + return new CallbackDisposable(function () use ($loop, $timer) { + $loop->cancelTimer($timer); }); }); @@ -206,8 +206,8 @@ public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDi $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($timer) { - $timer->cancel(); + return new CallbackDisposable(function () use ($loop, $timer) { + $loop->cancelTimer($timer); }); });