Packageorg.springextensions.actionscript.core.event
SVN browsingEventBus.as
FisheyeEventBus.as
Classpublic final class EventBus

The EventBus is used as a publish/subscribe event mechanism that lets objects communicate with eachother in a loosely coupled way.

Objects interested in receiving events can either implement the IEventBusListener interface and add themselves as listeners for all events on the event bus via the EventBus.addListener() method, if they are only interested in some events, they can add a specific event handler via the EventBus.addEventListener() method. The last option is too subscribe to events of a specific Class, use the

EventBus.addEventClassListener() for this purpose.

To dispatch an event, invoke the EventBus.dispatchEvent() or EventBus.dispatch() method.



Documentation reference: the eventbus introduction


Protected Properties
 PropertyDefined by
  _classListeners : Dictionary
[static] The Dictionary<Class,Function[]> that holds a mapping between event classes and a list of listener functions
EventBus
  _classProxyListeners : Dictionary
[static] The Dictionary<Class,MethodInvoker[]> that holds a mapping between event classes and a list of listener proxies
EventBus
  _eventListenerProxies : Object
[static] A map of event types/names with there corresponding proxied handler functions.
EventBus
  _eventListeners : Object
[static] A map of event types/names with there corresponding handler functions.
EventBus
  _listeners : ListenerCollection
[static] The IEventBusListener objects that listen to all events on the event bus.
EventBus
Public Methods
 MethodDefined by
  
addEventClassListener(eventClass:Class, listener:Function, useWeakReference:Boolean = false):void
[static] Adds a listener function for events of a specific Class.
EventBus
  
addEventClassListenerProxy(eventClass:Class, proxy:MethodInvoker, useWeakReference:Boolean = false):void
[static] Adds a proxied event handler as a listener for events of a specific Class.
EventBus
  
addEventListener(type:String, listener:Function, useWeakReference:Boolean = false):void
[static] Adds the given listener function as an event handler to the given event type.
EventBus
  
addEventListenerProxy(type:String, proxy:MethodInvoker, useWeakReference:Boolean = false):void
[static] Adds a proxied event handler as a listener to the specified event type.
EventBus
  
addListener(listener:IEventBusListener, useWeakReference:Boolean = false):void
[static] Adds the given listener object as a listener to all events send via the event bus.
EventBus
  
dispatch(type:String):void
[static] Convenience method for dispatching an event.
EventBus
  
dispatchEvent(event:Event):void
[static] Dispatches the specified Event on the event bus.
EventBus
  
removeAll():void
[static] Clears the entire EventBus by removing all types of listeners.
EventBus
  
removeEventClassListener(eventClass:Class, listener:Function):void
[static] Removes a listener function for events of a specific Class.
EventBus
  
removeEventClassListenerProxy(eventClass:Class, proxy:MethodInvoker):void
[static] Removes a proxied event handler as a listener for events of a specific Class.
EventBus
  
removeEventListener(type:String, listener:Function):void
[static] Removes the given listener function as an event handler from the given event type.
EventBus
  
removeEventListenerProxy(type:String, proxy:MethodInvoker):void
[static] Removes a proxied event handler as a listener from the specified event type.
EventBus
  
[static] Removes the given listener from the event bus.
EventBus
Property detail
_classListenersproperty
protected static var _classListeners:Dictionary

The Dictionary<Class,Function[]> that holds a mapping between event classes and a list of listener functions

_classProxyListenersproperty 
protected static var _classProxyListeners:Dictionary

The Dictionary<Class,MethodInvoker[]> that holds a mapping between event classes and a list of listener proxies

_eventListenerProxiesproperty 
protected static var _eventListenerProxies:Object

A map of event types/names with there corresponding proxied handler functions.

_eventListenersproperty 
protected static var _eventListeners:Object

A map of event types/names with there corresponding handler functions.

_listenersproperty 
protected static var _listeners:ListenerCollection

The IEventBusListener objects that listen to all events on the event bus.

Method detail
addEventClassListener()method
public static function addEventClassListener(eventClass:Class, listener:Function, useWeakReference:Boolean = false):void

Adds a listener function for events of a specific Class.

Parameters
eventClass:Class — The specified Class.
 
listener:Function — The specified listener function.
 
useWeakReference:Boolean (default = false)
addEventClassListenerProxy()method 
public static function addEventClassListenerProxy(eventClass:Class, proxy:MethodInvoker, useWeakReference:Boolean = false):void

Adds a proxied event handler as a listener for events of a specific Class.

Parameters
eventClass:Class — The specified Class.
 
proxy:MethodInvoker — The specified listener function.
 
useWeakReference:Boolean (default = false)
addEventListener()method 
public static function addEventListener(type:String, listener:Function, useWeakReference:Boolean = false):void

Adds the given listener function as an event handler to the given event type.

Parameters
type:String — the type of event to listen to
 
listener:Function — the event handler function
 
useWeakReference:Boolean (default = false)
addEventListenerProxy()method 
public static function addEventListenerProxy(type:String, proxy:MethodInvoker, useWeakReference:Boolean = false):void

Adds a proxied event handler as a listener to the specified event type.

Parameters
type:String — the type of event to listen to
 
proxy:MethodInvoker — a proxy method invoker for the event handler
 
useWeakReference:Boolean (default = false)
addListener()method 
public static function addListener(listener:IEventBusListener, useWeakReference:Boolean = false):void

Adds the given listener object as a listener to all events send via the event bus.

Parameters
listener:IEventBusListener
 
useWeakReference:Boolean (default = false)
dispatch()method 
public static function dispatch(type:String):void

Convenience method for dispatching an event. This will create an Event instance with the given type and call dispatchEvent() on the event bus.

Parameters
type:String — the type of the event to dispatch
dispatchEvent()method 
public static function dispatchEvent(event:Event):void

Dispatches the specified Event on the event bus.

Parameters
event:Event — The specified Event.
removeAll()method 
public static function removeAll():void

Clears the entire EventBus by removing all types of listeners.

removeEventClassListener()method 
public static function removeEventClassListener(eventClass:Class, listener:Function):void

Removes a listener function for events of a specific Class.

Parameters
eventClass:Class — The specified Class.
 
listener:Function — The specified listener function.
removeEventClassListenerProxy()method 
public static function removeEventClassListenerProxy(eventClass:Class, proxy:MethodInvoker):void

Removes a proxied event handler as a listener for events of a specific Class.

Parameters
eventClass:Class — The specified Class.
 
proxy:MethodInvoker — The specified listener function.
removeEventListener()method 
public static function removeEventListener(type:String, listener:Function):void

Removes the given listener function as an event handler from the given event type.

Parameters
type:String
 
listener:Function
removeEventListenerProxy()method 
public static function removeEventListenerProxy(type:String, proxy:MethodInvoker):void

Removes a proxied event handler as a listener from the specified event type.

Parameters
type:String
 
proxy:MethodInvoker
removeListener()method 
public static function removeListener(listener:IEventBusListener):void

Removes the given listener from the event bus.

Parameters
listener:IEventBusListener