Finesse Container Timer
Because too many timers that run concurrently can cause issues for JavaScript, you should not use setTimeout() or setInterval() directly. The Finesse container provides a service (the TimerTickEvent) that you can leverage for your third-party gadgets.
Finesse publishes the TimerTickEvent to the OpenAJAX hub every 1000 milliseconds. To use this service:
-
Have the gadget subscribe to the TimerTickEvent:
-
Define a callback method (see boilerplate gadget tick code - _timerTickHandler()) and, optionally, an update method (see boilerplate gadget tick code - _processTick()).
Cisco provides a boilerplate gadget tick code that you can use to define the callback method.
Boilerplate gadget tick code:
If you choose not to use the boilerplate gadget tick code, you should ensure the following:
-
Callback calculates entry and exit time.
-
Callback for timer tick is quick (log when callback takes to long - only when exceeding threshold).
-
Callback provides discard capability (as outlined in the boilerplate gadget tick code) to prevent events from piling up.
-
Callback adds a _lastProcessedTimerTick and uses it to force an update to occur at regular intervals (such as every 10 seconds). The intent is to prevent starvation in a heavily-loaded system that cannot respond quickly enough, such that all events are being discarded.
Note | Because the timer callback triggers every 1 second and the JavaScript engine is single-threaded, it is important to process as quickly as possible. Using the boilerplate code makes gadget development issues more obvious and easier to debug. |