How to add your knowledge

Events

    Table of contents
    No headers

    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:

    • FUSION_ERROR. This is triggered when an internal error happens. Details on the error are passed to the callback function. Applications should register for this event before calling Fusion.initialize() to ensure that they receive errors that happen during initialization.
    • FUSION_INITIALIZED. This is triggered when Fusion's initialization is complete and the application is running. This signals that it is safe for the application to communicate with specific components. Note that the Map component, specifically, will be ready but may not have actually loaded the map. There is a separate event for that. (See The Map Widget.) Applications should register for this event before calling Fusion.initialize().

    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.