Class: Toybox.Timer.Timer

Toybox.Lang.Object show all


A Timer object will invoke a callback function after a specified number of milliseconds.

There are two types of timers: one-shot or repeating. A one-shot Timer will only run once after the Timer expires, while a repeating Timer will invoke the callback function every n milliseconds until stop() is called. If a repeating Timer fails to run before its next execution time, then any missed executions will be skipped.

The number of available timers (default 3) and the minimum time value (default 50 ms) depends on the host system. An error will occur if too many timers are set.


Create a counter that increments by one each second

using Toybox.Timer;
var myCount =  0;

function timerCallback() {
    myCount += 1;

function onLayout(dc) {
    var myTimer = new Timer.Timer();
    myTimer.start(method(:timerCallback), 1000, true);


API Level 1.0.0

Instance Method Summary collapse

Instance Method Details

start(callback as Lang.Method() as Void, time as Lang.Number, repeat as Lang.Boolean) as Void

Start the Timer.


Will cause an app crash if called from a watch face app while in low power mode


  • callback(Lang.Method)

    A function to call after the Timer completes

  • time(Lang.Number)

    The number of milliseconds to wait before invoking callback

  • repeat(Lang.Boolean)

    Set to true to have the Timer repeat until stop() is called


API Level 1.0.0

stop() as Void

Stops the Timer from running.

This only needs to be called for repeating timers. A Timer can be started again by calling start().


API Level 1.0.0

Generated Apr 17, 2024 9:40:38 AM