421p / stimer
React-Eventloop compatible pausable timer.
0.2
2018-04-12 20:20 UTC
Requires
- php: >=7
- evenement/evenement: ^2.0
- react/event-loop: ^0.4.3
This package is auto-updated.
Last update: 2024-10-23 13:33:17 UTC
README
And immediately proceed to the samples:
Regular timer:
$loop = Factory::create(); $interval = 5; $timer = new Timer($loop, $interval, function () { echo 'hello world'; }); // ... 3 seconds $timer->pause(); $timer->getLeftInterval(); // ~ 2 seconds // ... something happens $timer->resume(); // ... 2 seconds // hello world
Periodic timer:
$loop = Factory::create(); $interval = 5; $timer = new PeriodicTimer($loop, $interval, function () { echo 'hello world'; }); // ... 3 seconds $timer->pause(); $timer->getLeftInterval(); // ~ 2 seconds // ... something happens $timer->resume(); // ... 2 seconds // hello world // ... 5 seconds // hello world