Skip to content

renatopp/timer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@gamestdio/timer Build Status

Timing Events tied to @gamestdio/clock.

ClockTimer is a subclass of Clock, which adds methods to handle timeout and intervals relying on Clock's ticks.

Why?

Once built-in setTimeout and setInterval relies on CPU load, functions may delay an unexpected amount of time to execute. Having it tied to a clock's time is guaranteed to execute in a precise way.

See a quote from W3C Timers Specification:

This API does not guarantee that timers will fire exactly on schedule. Delays due to CPU load, other tasks, etc, are to be expected.

API

Clock

  • setInterval(handler, time, ...args) -> Delayed
  • setTimeout(handler, time, ...args) -> Delayed
  • clear() - clear all intervals and timeouts.

Delayed

  • clear() -> void - Clear timeout/interval
  • reset() -> void - Reset elapsed time
  • active -> Boolean - Is it still active?
  • pause() -> void - Pause the execution
  • resume() -> void - Continue the execution
  • paused -> Boolean - Is is paused?

License

MIT

About

Timing Events tied to @gamestdio/clock

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • TypeScript 100.0%