Timer npm bundle size (scoped) npm

Class : public class Timer
Inheritance : Timer > EventDispatcher > Object

The Timer class is the interface to setTimeout and setInterval, and is totally ripped off from the AS3 Timer class, but simplified. This class depends on EventDispatcher. Use the start() method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.

You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule.

Installation

npm install --save @danehansen/timer

Usage

As a module:

import Timer from '@danehansen/timer';

var t = new Timer(500);
function onTimer(evt) {
  console.log(evt.target.currentCount());
}
t.addEventListener(Timer.TIMER, onTimer);

In your browser:

<script src='danehansen-Timer.min.js'></script>
<script>
  var Timer = window.danehansen.Timer;

  var t = new Timer(500);
  function onTimer(evt) {
    console.log(evt.target.currentCount());
  }
  t.addEventListener(Timer.TIMER, onTimer);
</script>

Public Constants

Public Properties

Public Methods

Events