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
- When the value of a UI control changes, it will use an action
to propagate that change to the model.
- Usually a control will execute a
<fx-setvalue>
action to change
its value - The action mutates the ModelItem state object that is associated to the control.
- The changed ModelItem is added to a
changed
array in the Model - When the action has done its job it will call the model to update while executing
actionPerformed()
. - Only actions that mutate the structure of the data will call
rebuild()
as the Main Dependency Graph needs
to be reconstructed. - 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. - The array of changed ModelItems will be cloned and passed as
toRefresh[]
to the Fore object. - All ModelItems will be revalidated.
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.- A
refresh-done
event is emitted - A
action-performed
event is emitted