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.
Fusion. | 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. | |
Fusion. |
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));
eventID | the event ID to register for |
f | the function to call when the event happens. |
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}.
this.callbackFn = OpenLayers.Function.bind(this.callback, this); otherObj.registerForEvent(SOME_EVENT, this.callbackFn); otherObj.deregisterForEvent(SOME_EVENT, this.callbackFn);
eventID | the event ID to deregister |
f | the function that used when registering. |
destroy: function()
register an event ID so that others can use it.
registerEventID : function( eventID )
register for receiving a callback when an event happens.
registerForEvent : function( eventID, f )
deregister a callback function when you no longer want to recieve it.
deregisterForEvent : function( eventID, f )
trigger an event and call all registered listener functions.
triggerEvent : function( eventID )