org.as2lib.core.BasicClass +--org.as2lib.env.event.TypeSafeEventListenerSource +--org.as2lib.env.event.distributor.AbstractEventDistributorControl +--org.as2lib.env.event.distributor.SimpleEventDistributorControl
EventDistributorControl
SimpleEventDistributorControl
acts as a listener source and event
distributor control. It enables you to distribute and handle events in the
safest way possible by providing a compiler-safe distributor.
Example:
// creates a distributor control with the expected listener type
var distributorControl:SimpleEventDistributorControl = new SimpleEventDistributorControl(ErrorListener);
// adds new listeners that must be of the expected type
distributorControl.addListener(new MyErrorListener());
distributorControl.addListener(new SimpleErrorListener());
// gets a distributor to distribute the event to all listeners
var distributor:ErrorListener = ErrorListener(distributorControl.getDistributor());
// distributes the event with custom arguments
distributor.onError(myErrorCode, myException);
new SimpleEventDistributorControl()
addAllListeners(), addListener(), getAllListeners(), getListenerType(), hasListener(), isListenerTypeChecked(), removeListener()
public function SimpleEventDistributorControl(listenerType:Function, checkListenerType:Boolean, listeners:Array)
Constructs a new SimpleEventDistributorControl
instance.
checkListenerType
is by default set to true
.
listenerType | the expected type of listeners |
checkListenerType | determines whether to check that passed-in listeners are of the expected type |
listeners | (optional) the listeners to add |
IllegalArgumentException | if the passed-in listenerType is
null or undefined
|
public function removeAllListeners(Void):Void
Removes all added listeners.
removeAllListeners() in org.as2lib.env.event.EventListenerSource
removeAllListeners() in org.as2lib.env.event.TypeSafeEventListenerSource