Events

The event code is designed to provide an asynchronous notification mechanism that can be used to register for, and receive notification of, key events that happen asynchronously. The following terms are used with respect to events:

  1. event id: a unique identifier for an event, represented by a JavaScript variable that is all in upper case (e.g FUSION_INITIALIZED). All event IDs are properties of the Fusion.Event object.
  2. trigger: when an event occurs, it is “triggered” and all the registered callback functions are notified
  3. register: provide a callback function that is called when an event is triggered
  4. deregister: remove a callback function that was previously registered
  5. publish: anything that can trigger an event must publish all the valid event IDs

The event mechanism is implemented by two functions: registerForEvent and deregisterForEvent. Both functions have the same signature, taking an event ID as the first parameter and a callback function pointer as the second parameter.

The Fusion object provides two specific events that can be used by applications to get notification of when Fusion initialization has completed and when an error occurs anywhere in Fusion. These events are:

Components are designed to be completely independent of one another, allowing them to be added to, or removed from, applications with little or no impact on the other components in the application. However, there are cases (especially with the Map component) where it is important that components be able to communicate with other components or with the application as a whole. For these situations, there is an event mechanism that allows components and applications to register for and trigger events. The event mechanism allows components to be independent of each other, but still provide a high level of integration when required. For more information on the events supported by the Map component, see Working With Maps and Working With Selections.

To register a callback function for a component event, the application must first obtain a reference to the component through one of the methods of the Fusion object (typically getWidgetById) and then call registerForEvent passing one of the event IDs that is valid for that component.