Skip to content

Stopwatch

Malexion edited this page Nov 7, 2016 · 1 revision

new __.lib.StopWatch([options])

  • [options] [Optional] option params for stopwatch settings and tick event handler.

Examples

var stopwatch = new __.lib.StopWatch({
   onTick: (time) => {
      console.log(time);
   },
   tickRate: 100 // in ms
});

stopwatch.start();

setTimeout(() => {
   stopwatch.stop();
   console.log('We Stopped!');
   stopwatch.start();

   setTimeout(() => {
      stopwatch.stop();
      console.log('Last Stop!');
      stopwatch.reset();
      console.log(stopwatch.getTime());
   }, 5000);
}, 5000);

Clone this wiki locally