Timer
Timer Module
Set Interval
Timer method setInterval
can be used to apply
recurring action on given interval in miliseconds
TypeScript
this.id = setInterval(() => {
let randNumber = Math.floor(Math.random() * (that.color.length));
that.buttoncolor = that.color[randNumber];
}, 1000);
Set Timeout
Timer method setTimeout
can be used to delay the
execution of an action in miliseconds.
TypeScript
setTimeout(() => {
this.counter--;
button.backgroundColor = new Color("#30BCFF");
}, 1000);
API Reference for the Timer Class