voltmx.timer Namespace
The voltmx.timer namespace implements the Timer API. It contains the following API elements.
Functions
The voltmx.timer namepace provides the following functions.
voltmx.timer.cancel
This API cancels the timer that has already been scheduled for execution.
Syntax
voltmx.timer.cancel(timerid)
Input Parameters
Parameter | Description |
---|---|
timerid [String] - Mandatory | Specifies the unique ID that identifies the timer that needs to be canceled. |
Example
Return Values
None
Exceptions
Error
Error Codes
- 100 - invalid arguments
- 101 - internal error
Implementation Details
If the timer is waiting to be run, it will not be run the next time. If the timer is in the middle of execution, it will be allowed to complete and then canceled.
Platform Availability
Available on all platforms*. *Dummy Implementation on Mobile Web.
voltmx.timer.setCallBack
This API specifies the callback function that needs to be executed for a scheduled timer. The callback function handles the logic that needs to be executed after a scheduled timer was run successfully or the scheduled timer failed to execute. The setCallBack timer API is provided to override the existing time call back function which is defined in the “schedule” timer API.
Syntax
voltmx.timer.setCallBack(timerid, callbackfunction)
Input Parameters
Parameter | Description |
---|---|
timerid [String] - Mandatory | Specifies the unique ID that identifies the timer. |
callbackfunction [Function] - Mandatory | Specifies the callback function that needs to be executed. |
Example
Return Values
None
Exceptions
Error
Platform Availability
Available on all platforms*. *Dummy Implementation on Mobile Web.
voltmx.timer.schedule
This API executes the given function after a specified interval of time.
Use Cases
You can use this API when you want to execute a function after a specified interval of time. i.e, for example to run a specific function for every 15 seconds.
Syntax
voltmx.timer.schedule(timerid, functionObj, interval, repeat)
Input Parameters
Parameter | Description |
---|---|
timerid [String] - Mandatory | Specifies the unique ID that identifies the timer. |
functionObj [Function] - Mandatory | Specifies the function that needs to be executed. |
interval [Number] - Mandatory | Specifies the time in seconds after which the function needs to be executed. |
repeat [Boolean] - Mandatory | Specifies a flag that indicates if the function needs to executed once or repeated.true - indicates that the execution of the function needs to repeated at regular intervals_false_ - indicates that the function needs to be executed just once |
Example
Return Values
None
Exceptions
Error
Platform Availability
Available on all platforms*. *Dummy Implementation on Mobile Web.