Prototype JavaScript framework

class PeriodicalExecuter

Description

A class that oversees the calling of a particular function periodically.

PeriodicalExecuter shields you from multiple parallel executions of the callback function, should it take longer than the given interval to execute.

This is especially useful if you use one to interact with the user at given intervals (e.g. use a prompt or confirm call): this will avoid multiple message boxes all waiting to be actioned.

Methods

Constructor

new PeriodicalExecuter(callback, frequency)
  • callback (Function) – the function to be executed at each interval.
  • frequency (Number) – the amount of time, in sections, to wait in between callbacks.

Creates an PeriodicalExecuter.

Instance methods

  • stop

    PeriodicalExecuter#stop() -> undefined

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