I'm trying to create a self contained timer where all variables are inside a object.
For the most part it works but I can get this to fire once. What am I missing?
function Countdown()
{
this.appId = null;
this.timerId = null;
this.seconds = null;
this.decrementCounter = function (instant)
{
if (instant == null)
return;
instant.tick();
if (instant.seconds === 0)
{
instant.tickEnd();
instant.stop();
}
instant.seconds--;
};
this.tick = function ()
{
var xx = this.appId
};
this.tickEnd = function ()
{
var xx = this.appId
};
this.start = function ()
{
clearInterval(this.timerId);
this.timerId = setInterval(this.decrementCounter(this), 1000);
};
this.stop = function ()
{
clearInterval(this.timerId);
};
}