Skip to content

CodeRADEvents

Steve Hannah edited this page Jul 5, 2021 · 3 revisions

Events

CodeRAD apps are event-driven. Events are used for most communication between loosley-coupled components. Some events originate from the user via interaction with the view. Such events are dispatched and propagated up the controller hierarchy until it is either consumed or it reaches the top of the hierachy (i.e. the application controller).

The following diagram depicts this flow in a scenario where the originating UI component doesn’t have a dedicated ViewController. In this scenario a user event occurs, so the event propagates up the UI hierarchy until it reaches the Form, which has a FormController, so the event is passed to that FormController, which processes it and passes it to its parent controller, which is the ApplicationController.

EventPropagationFlow
Figure 1. Example event flow where the component triggers an event, and it is dispatched to the Form’s registered FormController.
Note
In this diagram we know that none of Containers in the "up-line" between the Component and the Form have a registered ViewController, because if one had, then the event would have been passed to that view controller first, rather than propagating directly to the FormController.

The next digram shows a more complex scenario where the UI component has its own ViewController.

EventPropagationFlow2
Figure 2. Example of event flow when triggering component has a registered ViewController.

In this case the event is passed to the component’s ViewController first. It processes the event and passes it up to the FormController, which processes it and propagates it up to the ApplicationController.

Note
If the event had been consumed at any step, the propagation would be cancelled. E.g. If the ViewController had consumed the event, then it would not be passed to the FormController for processing.

The next example adds an additional FormController to the navigation stack. In this case, the event will propagate up through the FormController’s parent FormController before it reaches the ApplicationController.

EventPropagationFlow3
Figure 3. Example event flow with two levels of FormController in the controller hierarchy. The event passes through both FormControllers on the way up to the ApplicationController.

"Action" Events

The most common type of event is one that is triggered by an Action. CodeRAD provides special support for this type of event. See Actions for more information about Actions.

Handling Events

TODO

Dispatching Events

TODO

Clone this wiki locally