The Timer API is used to create, start, stop and check the existence of timers.
## Enabling the API This API is part of the `coreapi` extension that is included automatically. extensions: ["coreapi"] ## JavaScript Usage Be sure to review the [JavaScript API Usage](/guide/api_js) guide for important information about using this API in JavaScript. ## Ruby Usage Be sure to review the [Ruby API Usage](/guide/api_ruby) guide for important information about using this API in Ruby.
Create timer object(s).
Synchronous Return:
Method Access:
Rho.Timer.create()
Rho::Timer.create()
Synchronous Return:
Return alive state of a timer. If callback doesn’t return true, returns false.
Method Access:
myObject.isAlive()
Start timer with preset interval. Callback fired one time only.
Parameters
timer interval in ms
Async Callback Returning Parameters: STRING
Synchronous Return:
Method Access:
myObject.start(INTEGER interval, CallBackHandler callback)
Stop the timer.
Synchronous Return:
Method Access:
myObject.stop()
Implementation of the timer API.
// Create a timer and catch callback after the specified interval: var timerCallback = function() { alert("callback called"); } var timer = Rho.Timer.create(); timer.start(5000, timerCallback); Create a timer, start and stop: var timerCallback = function() { alert("callback called"); } var timer = Rho.Timer.create(); timer.start(5000, timerCallback); setTimeout(function() { timer.stop(); },3000);