Hierarchy

  • EventEmitter
    • Timer

Constructors

Properties

Accessors

Methods

Constructors

  • Constructs a new instance of the timer

    Note: If additional arguments are specified, then those arguments will be provided with every tick event emitted except arguments that may be included with calls to the tick() method.

    Parameters

    • interval: number
    • autoStart: boolean = false
    • Rest ...args: any[]

    Returns Timer

Properties

interval: number
paused: boolean = true

Accessors

  • get destroyed(): boolean
  • Returns if the timer has been destroyed

    Returns boolean

Methods

  • Destroys the timer

    Note: This is destructive, once destroyed, it cannot be restarted

    Returns void

  • Event that is emitted only once when we start the timer

    Parameters

    • event: "start"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted only once when we stop the timer

    Parameters

    • event: "stop"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted only once when a tick occurs

    Parameters

    • event: "tick"
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Event that is emitted only once when we have an error

    Parameters

    • event: "error"
    • listener: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns this

  • Event that is emitted every time a tick occurs

    Parameters

    • event: "tick"
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Event that is emitted when we have an error

    Parameters

    • event: "error"
    • listener: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns this

  • Event that is emitted when we start the timer

    Parameters

    • event: "start"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted when we stop the timer

    Parameters

    • event: "stop"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted only once when we start the timer

    Parameters

    • event: "start"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted only once when we stop the timer

    Parameters

    • event: "stop"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Event that is emitted only once when a tick occurs

    Parameters

    • event: "tick"
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Event that is emitted only once when we have an error

    Parameters

    • event: "error"
    • listener: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns this

  • Starts the timer

    Returns void

  • Stops the timer

    Returns void

  • Forces a tick event to be emitted with the specified arguments

    Parameters

    • Rest ...args: any[]

    Returns void

  • Toggles the timer on/off

    Returns boolean

    boolean whether the timer is running or not