Skip to content

CallbackTimer

Overview

CallbackTimer is a timer that calls a set of registered callbacks. It utilizes AXON/stepTimer, but provides a higher level of abstraction, hiding the details of managing stepTimer.

@author Chris Malley (PixelZoom, Inc.)

Class CallbackTimer

import { CallbackTimer } from 'scenerystack/axon';

Constructor

new CallbackTimer( options? : CallbackTimerOptions )

Instance Methods

isRunning() : boolean

start()

stop( fire : boolean )

Stops the timer. @param fire - should we fire if we haven't fired already?

addCallback( callback : CallbackTimerCallback )

removeCallback( callback : CallbackTimerCallback )

fire()

Calls all callbacks. Clients are free to call this when the timer is not running.

dispose()

Type CallbackTimerCallback

import type { CallbackTimerCallback } from 'scenerystack/axon';

() => void

Type CallbackTimerOptions

import type { CallbackTimerOptions } from 'scenerystack/axon';
  • callback?: CallbackTimerCallback
    convenience for adding 1 callback
  • delay?: number
    start to fire continuously after pressing for this long, in ms
  • interval?: number
    fire continuously at this interval, in ms

Source Code

See the source for CallbackTimer.ts in the axon repository.