Packagecom.developmentarc.framework.utils
Classpublic class EventBroker

The EventBroker is a remote Observer pattern that allows objects to subscribe to events that may be broadcasted by any item in the system. This utility is useful for situations where the broadcaster may not be a direct child or could change as the application is run. The EventBroker allows for any object to subscribe to any event that is broadcasted through the broker. The subscriber must provide a callback that accepts one argument of type Event.

The EventBroker is a Static object which means that all access must be made through the static methods. The class is a facade Singleton which means that even though you are calling a static method a singleton object is defined so that only one instance of the EventBroker exists.



Public Methods
 MethodDefined by
  
broadcast(event:Event):void
[static] Called by an object that wishes to broadcast an event.
EventBroker
  
[static] Removes all subscribed methods and objects from the EventBroker.
EventBroker
  
subscribe(eventType:String, callback:Function):void
[static] Enables any object to subscribe to any event type by providing the Event type and the callback method the EventBroker should call when an Event of the requested type is broadcasted.
EventBroker
  
unsubscribe(eventType:String, callback:Function):void
[static] Removes subscription of the specified event and callback.
EventBroker
Method detail
broadcast()method
public static function broadcast(event:Event):void

Called by an object that wishes to broadcast an event. All subscribers of the event type will be called and passed the provided Event.

Parameters
event:Event — The Event to broadcast to the subscriber set.
clearAllSubscriptions()method 
public static function clearAllSubscriptions():void

Removes all subscribed methods and objects from the EventBroker.

subscribe()method 
public static function subscribe(eventType:String, callback:Function):void

Enables any object to subscribe to any event type by providing the Event type and the callback method the EventBroker should call when an Event of the requested type is broadcasted. The callback must be a single argument method that accepts type Event.

Parameters
eventType:String — The Event type to subscribe to.
 
callback:Function — The method to call when the event type is broadcasted.
unsubscribe()method 
public static function unsubscribe(eventType:String, callback:Function):void

Removes subscription of the specified event and callback.

Parameters
eventType:String
 
callback:Function