Commands, Events, and States
Commands and Events
Commands provide a mechanism that allows application components to invoke functionality without knowing who the actual implementer(s) are. They live inside of the application’s CommandRegistry
object. Referencing a non-existent command simply creates a new empty command.
Commands are invoked by name and can have zero or more implementations registered. These implementations are executed sequentially when a command is invoked. Since commands can be invoked from workflows via the RunExternalCommand
activity, it is better to keep command parameters as simple as possible.
Commands do not return results, and should generally not modify their arguments.
Events are similar to commands. Events allow components to respond to events in a system. Events, like commands, are referenced by name and contain zero or more pieces of functionality that are executed sequentially when the event is published.
Events differ from regular JavaScript and Dojo events in that they are not global. Geocortex events live inside the scope of an application instance and so multiple applications can live on a page without interfering with each other's events.
See Viewer Commands and Events for more information.
Modules that interact with each other should always do so via commands and events. Modules should never have explicit coupling. Removing one module should not break another.
States
Geocortex Viewer for HTML5 2.5 introduces the notion of application states. States are a means to provide context as to what is currently happening in the viewer. States are entered or exited when a certain command runs, a specific event occurs, or in response to user activity. For example, IdentifyState
is activated when the Identify tool becomes active.
There are two kinds of states:
-
Global States: Only a single global state can be active at a time. If a new global state activates, the previous one becomes inactive. For example,
IdentifyState
cannot be active at the same time asMeasureState
. A global state can, however, be active at the same time as any number of non-global states. -
Non-global States: Any number of non-global states can be active simultaneously—regardless of whether a global state is active or not. For example,
TransientActiveState
andSnappingState
can be active simultaneously.
There is also a default non-modal state, DefaultState
, which is always active, even when no other states are active.
States are typically associated with:
-
Toggle buttons, which can be configured in Geocortex Essentials Manager.
-
Context-sensitive toolbars, which are configured in the
transientElements
array of both the TabbedToolbar Module and the CompactToolbar Module. These toolbars can contain buttons or toggle buttons.
See also...