Update Cycle

The update cycle is triggered whenever a user interacts with a control e.g. by changing its value.

Likewise this can be triggered by Actions being triggered by some state event like e.g. value-changed event.

sequenceDiagram autonumber participant User participant Control participant Action participant Model participant Fore User->>Control: interact Control->>Action: execute activate Action Action->>Action: mutate ModelItem Action->>Model: add to changed list activate Action Action->>Action: actionPerformed() Action->>Model: rebuild() Action->>Model: recalculate() Action->>Fore: changed[] -> toRefresh[] Action->>Model: revalidate() Action->>Fore: refresh() Fore-->>Fore: refresh-done deactivate Action Action-->>Action: action-performed deactivate Action
  1. When the value of a UI control changes, it will use an action to propagate that change to the model.
  2. Usually a control will execute a <fx-setvalue> action to change its value
  3. The action mutates the ModelItem state object that is associated to the control.
  4. The changed ModelItem is added to a changed array in the Model
  5. When the action has done its job it will call the model to update while executing actionPerformed().
  6. Only actions that mutate the structure of the data will call rebuild() as the Main Dependency Graph needs to be reconstructed.
  7. Instead of using MDG (see Initialization) recalculate will re-compute all calculations for the changed nodes by creating a subgraph of the MDG that will only contain the affected ModelItems.
  8. The array of changed ModelItems will be cloned and passed as toRefresh[] to the Fore object.
  9. All ModelItems will be revalidated.
  10. refresh() is called on Fore object that will use the toRefresh array of changed ModelItems to selectively update only affected controls. This will also incorporate controls that are dependent on the changed one by using the MDG.
  11. A refresh-done event is emitted
  12. A action-performed event is emitted