
~~Title: Utilities API~~

<html><font color=#990000 size="+2"><b>Utilities API</b></font></html>

The <color #00a2e8>Real-Time AI</color> application platform provides a series of internal utiity libraries for dealing with common tasks.

\\

==== Data Source Methods ====

Data Sources

  *  ''component.ds..'': Returns a //Shared Variable// value defined for this component.

==== Timer Methods ====

Data Sources

  *  ''component.timer.start()'': Starts a //Timer// loop.
  *  ''component.timer.start(false)'': Starts a //Timer// and //false// to skip delay and start right away.
  *  ''component.timer.stop()'': Stops a //Timer// loop.
  *  ''component.timer.isStarted()'': Chercks to see if the //Timer// is started.

{{:wiki:rtai:timer_1.png|}}

Only one //timer// can exist for a given component.  The //timer// supports triggers:

{{:wiki:rtai:timer_2.png|}}

'execute' will be triggered periodically as per 'interval' option.
if 'delay' is not zero - first execution will happen after given delay
by default timer is not started and you have options to start it on component is ready
or on component is ready and first data loaded.

'complete' trigger will be executed, if you returned some promise from 'execute'. 
In that case timer will be on hold until this promised will be resolved.

for example in 'execute' you do 
return component.fetchData();
fetchData is async function and it returns promise, not an instant result data.
In that case 'complete' trigger will be executed and result data will come to it as argument.

'fail' trigger will be executed in case of any error happened in your triggers or network errors or HTTP erors.
