Skip to content

GotanDev/mtimer-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MTimer JS

Managed Timers (interval & timemout) for Javascript

Override default setInterval and setTimeout functions to allow better management.

Allows to list, stop, clear any launched timer.

Setup

  • NPM
npm i mtimer-js
  • Bower
bower install --save git@github.com:GotanDev/mtimer-js.git

Documentation

  • Just use setTimeout & setInterval, clearInterval, clearTimeout functions as usual
  • window.timers global variable includes now all active timers details.
    Each items has the following structure:
{
    id: Number,
    type: 'interval'|'timeout',
    functionName: String,
    delay: Number,
    startTime: Date
}
  • Additionally on overrided basic functions , you can also get 2 additionnal functions:
    • clearTimer(timerId:number):
      Clear a timer from its id
      (either created by setInterval ou setTimeout functions)
    • clearTimers(typeFilter: 'interval'|'timeout'):
      Reset all known active timers (timeouts and intervals) You can specify either timeout or interval
      Default value: both

Sample

CodePen

Licence

MIT

Releases

No releases published

Packages

No packages published