Triggers & Actions is a module provided by CG Client API combined with CG Server API.  The module goes beyond the basic act of presenting widgets, and is intend to be used mostly by developers, although some exposure may be available for end users. The module provides developers with the ability to define rules by which certain trigger invoke certain action on a given condition.

CG lets developers set Triggers and Actions conditions for manipulating widgets. Trigger is related with given state of an application in which some action need to be applied. Action is the actual operation that needs to be applied on one or more widget.

For example a scheduler mechanism can be used as the trigger got setting a flag on widget that indicate if a widget can be presented or not, so that widget will be presented on a Glass only for some specific period of time.

Triggers and actions can involve also interaction with Linkage Graph but this is not a must. Trigger and actions can be set programmatically for any set of widgets selected by a program. Using the Linkage Graph a user (or a program) can set triggers and actions for related widgets. For example: creating hierarchy of presentation between widgets on the same Glass. Widget-B can be presented only if Widget-A was previously presented, and Widget-C can be presented only if Widget-B was first presented and so on.

The mechanism has three stages:

  1. A rule needs to be defined. The rule determines a trigger type (source) and the condition on which this trigger will act of selected action. So we have the trigger type, the state and the action.
  2.  The state need to be checked repeatedly against rule settings
  3.  Once state of trigger source match the defined condition the action is fired.

Type of triggers

  1. Scheduler: action will be triggered on pre defined times or periodically each given amount of predefined time.
  2.  Software state: on some state an action will be invoked
  3. Widget state: a state of one widget is used as the trigger for setting and action on other widget.


Type of actions

  1. Visual changes, for example: Hide/Show widget, Change theme or style, Set text color
  2. Widget content, for example:  clear content,  Set fixed content,  Switch the content based on condition
  3.  Widget operation: perform some operation, for example send notification.
  4.  Run some code