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:

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:

See also...

State Reference