src code

instance method PeriodicalExecuter#stop

PeriodicalExecuter#stop() → undefined

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.

Example

This will only alert 1, 2 and 3, then the PeriodicalExecuter stops.

var count = 0;
new PeriodicalExecuter(function(pe) {
  if (++count > 3) {
    pe.stop();
  } else {
    alert(count);
  }
}, 1);