Interface nsITimerType

nsITimer instances must be initialized by calling one of the "init" methods documented below. You may also re-initialize (using one of the init() methods) an existing instance to avoid the overhead of destroying and creating a timer. It is not necessary to cancel the timer in that case.

By default a timer will fire on the thread that created it. Set the .target attribute to fire on a different thread. Once you have set a timer's .target and called one of its init functions, any further interactions with the timer (calling cancel(), changing member fields, etc) should only be done by the target thread, or races may occur with bad results like timers firing after they've been canceled, and/or not firing after re-initiatization.

Hierarchy

Properties

allowedEarlyFiringMicroseconds: number

The number of microseconds this nsITimer implementation can possibly fire early.

callback: nsITimerCallback

The nsITimerCallback object passed to initWithCallback.

closure: voidPtr

The opaque pointer pass to initWithFuncCallback.

delay: number

The millisecond delay of the timeout.

NOTE: Re-setting the delay on a one-shot timer that has already fired doesn't restart the timer. Call one of the init() methods to restart a one-shot timer.

target: nsIEventTarget

The nsIEventTarget where the callback will be dispatched. Note that this target may only be set before the call to one of the init methods above.

By default the target is the thread that created the timer.

type: number

The timer type - one of the above TYPE_* constants.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Cancel the timer. This method works on all types, not just on repeating timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse it by re-initializing it (to avoid object destruction and creation costs by conserving one timer instance).

    Returns void

  • Initialize a timer that will fire after the said delay. A user must keep a reference to this timer till it is is no longer needed or has been cancelled.

    Parameters

    • aObserver: nsIObserver

      the callback object that observes the ``timer-callback'' topic with the subject being the timer itself when the timer fires:

      observe(nsISupports aSubject, => nsITimer string aTopic, => ``timer-callback'' wstring data => null

    • aDelayInMs: number

      delay in milliseconds for timer to fire

    • aType: number

      timer type per TYPE* consts defined above

    Returns void

  • Initialize a timer to fire after the high resolution TimeDuration. This version takes a callback object.

    Parameters

    • aCallback: nsITimerCallback
    • aDelay: TimeDuration

      The high resolution interval

    • aType: number

      Timer type per TYPE* consts defined above

    Returns void

  • Initialize a timer to fire after the high resolution TimeDuration. This version takes a named function callback.

    Parameters

    • aCallback: nsTimerCallbackFunc
    • aClosure: voidPtr

      An opaque pointer to pass to that function

    • aDelay: TimeDuration

      The high resolution interval

    • aType: number

      Timer type per TYPE* consts defined above

    • aName: string

      The timer's name

    Returns void

  • Initialize a timer to fire after the given millisecond interval. This version takes a callback object.

    Parameters

    • aCallback: nsITimerCallback
    • aDelayInMs: number

      The millisecond interval

    • aType: number

      Timer type per TYPE* consts defined above

    Returns void

  • Like initWithFuncCallback, but also takes a name for the timer; the name will be used when timer profiling is enabled via the "TimerFirings" log module.

    Parameters

    • aCallback: nsTimerCallbackFunc
    • aClosure: voidPtr

      An opaque pointer to pass to that function

    • aDelay: number

      The millisecond interval

    • aType: number

      Timer type per TYPE* consts defined above

    • aName: string

      The timer's name

    Returns void

  • Parameters

    • aMallocSizeOf: MallocSizeOf

    Returns number

Generated using TypeDoc