Utility class to simplify use of timers created by setTimeout.
npm install chronoman
jspm install chronoman
bower install chronoman
jam install chronoman
Use dist/chronoman.js
or dist/chronoman.min.js
(minified version).
import Timer from "chronoman";
var Timer = require("chronoman");
var Timer = require("gamtiq/chronoman");
System.import("chronoman").then(function(Timer) {
...
});
require(["chronoman"], function(Timer) {
...
});
define(["path/to/dist/chronoman.js"], function(Timer) {
...
});
<!-- Use bower_components/chronoman/dist/chronoman.js if the library was installed by Bower -->
<script type="text/javascript" src="path/to/dist/chronoman.js"></script>
<script type="text/javascript">
// сhronoman is available via Chronoman field of window object
var Timer = Chronoman;
...
</script>
var nI = 0;
var tmrOne = new Timer({
period: 1000,
action: function(timer) {
console.log("---> Timer one. ", timer);
if (! tmrThree.isActive()) {
tmrThree.start();
}
}
});
var tmrTwo = new Timer();
tmrTwo.setPeriod(2000)
.setRepeatQty(9)
.setPassToAction(true)
.setAction(function(timer) {
nI ;
console.log("Timer two. #", nI, timer);
tmrOne.setActive(nI % 2 === 1);
});
var tmrThree = new Timer()
.setPeriod(3000)
.setRepeatTest(function() {
return tmrTwo.isActive();
});
tmrThree.onExecute = function() {
console.log("* Timer three. #", this.getExecutionQty() 1);
};
tmrTwo.start();
See doc
folder.
This module is inspired by qooxdoo's qx.event.Timer
class.
Copyright (c) 2013-2016 Denis Sikuler
Licensed under the MIT license.