stop

stop()

Stops the periodical executer (there will be no further triggers).

Once a PeriodicalExecuter is created, it constitues an infinite loop, triggering at the given interval until the page unloads. This method lets you stop it any time you want.

While there currently is a registerCallback method that technically re-enables the executer, it is unclear whether it is considered internal (and therefore should not be used as a feature) or not. In doubt, always instantiate a fresh PeriodicalExecuter when you need to start one.

Examples


var gCallCount = 0;
new PeriodicalExecuter(function(pe) {
  if (++gCallCount > 3)
    pe.stop();
  else
    alert(gCallCount);
}, 1);
// Will only alert 1, 2 and 3, then the PE stops.