421p/stimer

React-Eventloop compatible pausable timer.

Maintainers

Details

github.com/421p/stimer

Source

Issues

Installs: 354

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/421p/stimer

0.2 2018-04-12 20:20 UTC

This package is auto-updated.

Last update: 2025-09-23 15:20:00 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