Action Timer Screen Component

This component covers the need to repeat an action at separate intervals while on a screen. For example it gives us the possibility to execute a regular Ajax Update action, or trigger an action after a timeout.

The Action Timer screen component allows you to trigger actions repeatedly or after a timeout. Simply look for the Action Timer in the component library and drag an instance of it onto your screen. It has the following properties:

  • Name — Description of the timer
  • Start Delay (ms) — The time between when the page is loaded and the first action is executed (empty if the action shouldn't be delayed)
  • Interval (ms) — The time between each execution of the action (empty unless the action should be triggered repeatedly)
  • Duration (ms) — How long the actions should continue being triggered before completion (empty to keep triggering the action indefinitely)

Select the Action Timer component on the screen to fill out these properties. Then, actions can be specified on the component. The actions themselves can vary: we will look at a very simple example below.

Example: I want to increase, count and then display the number of lines in a collection every second. To achieve this, I can use an Action Timer to both increment the count and display the updated value.

  1. Initialize a collection in your Screen.

  2. Create an Action Timer instance along with a Text component to display the information.

    Set the timer properties after you’ve selected the Action Timer:

    This example runs the actions every second for the first 10 seconds, and then stops. All we have is a Text component within an Ajax component which updates the number displayed. The Text component has a counter with the number of items in our indexed collection.

  3. Create some actions to be performed upon timer trigger.

    The code within the script action is:

    Copy
     If SIZE($lines) == 0 Then 
       $lines := new Indexed String;
    End
    $lines.addElement('Another Empty String');
  4. Place your Screen within a Process and run it.

    The number of lines should count to 10 every second.

This solution can easily be extended to perform other actions, such as running timeout actions by redirecting to another screen, or even saving certain details on a periodic basis.