# Fusion.Lib.EventMgr

an internal class for managing generic events. Classes that wish to publish and trigger events that other objects can listen for need to inherit from Fusion.Lib.EventMgr.

To publish an event, call registerEventID with some unique numeric or string value. Other objects can then call registerForEvent with the eventID and a function to call when the event is triggered.

To trigger an event, call triggerEvent with the eventID and any additional arguments that should be passed to listeners.

Summary

Fusion.Lib.EventMgr | an internal class for managing generic events.
Functions |
destroy |
registerEventID | register an event ID so that others can use it.
registerForEvent | register for receiving a callback when an event happens.
deregisterForEvent | deregister a callback function when you no longer want to recieve it.
triggerEvent | trigger an event and call all registered listener functions.
Constants |
Fusion.Event.FUSION_INITIALIZED |
Fusion.Event.FUSION_ERROR |

### Functions

### destroy

> destroy: function()

### registerEventID

> registerEventID : function( | eventID | )

register an event ID so that others can use it. This should really only be called by ‘this’ object.

#### Parameters

eventID | the event ID to register

### registerForEvent

> registerForEvent : function( | eventID,
> | f | )

register for receiving a callback when an event happens. If you want the callback to be a method on an instance of some object, use the {<OpenLayers.Function.bind>} function as in:

otherObj.registerForEvent(SOME_EVENT, OpenLayers.Function.bind(this.callback,this));

#### Parameters

eventID | the event ID to register for
f | the function to call when the event happens.

### deregisterForEvent

> deregisterForEvent : function( | eventID,
> | f | )

deregister a callback function when you no longer want to recieve it. Note that if you used {<OpenLayers.Function.bind>} when registering, you need to pass EXACTLY THE SAME FUNCTION when deregistering. Typically, this means you need to assign the result of {<OpenLayers.Function.bind>} to an instance variable and pass that instance variable to both {Fusion.Lib.EventMgr.registerForEvent} and {Fusion.Lib.EventMgr.deregisterForEvent}.

#### For instance

this.callbackFn = OpenLayers.Function.bind(this.callback, this); otherObj.registerForEvent(SOME_EVENT, this.callbackFn); otherObj.deregisterForEvent(SOME_EVENT, this.callbackFn);

#### Parameters

eventID | the event ID to deregister
f | the function that used when registering.

### triggerEvent

> triggerEvent : function( | eventID | )

trigger an event and call all registered listener functions. This is intended to be called by ‘this’. The eventID param is mandatory. Any additional arguments will be passed to the listener function.

#### Parameters

eventID | the event ID to trigger

### Constants

### Fusion.Event.FUSION_INITIALIZED

### Fusion.Event.FUSION_ERROR

> destroy: function()

> registerEventID : function( | eventID | )

register an event ID so that others can use it.

> registerForEvent : function( | eventID,
> | f | )

register for receiving a callback when an event happens.

> deregisterForEvent : function( | eventID,
> | f | )

deregister a callback function when you no longer want to recieve it.

> triggerEvent : function( | eventID | )

trigger an event and call all registered listener functions.
Close