Class org.as2lib.env.event.distributor.SimpleEventDistributorControl

org.as2lib.core.BasicClass
   +--org.as2lib.env.event.TypeSafeEventListenerSource
      +--org.as2lib.env.event.distributor.AbstractEventDistributorControl
         +--org.as2lib.env.event.distributor.SimpleEventDistributorControl

Implemented Interfaces

EventDistributorControl

Description

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);

Method Index

new SimpleEventDistributorControl()

removeAllListeners()

Inherited from AbstractEventDistributorControl

getDistributor(), getType()

Inherited from TypeSafeEventListenerSource

addAllListeners(), addListener(), getAllListeners(), getListenerType(), hasListener(), isListenerTypeChecked(), removeListener()

Inherited from BasicClass

toString()

Constructor Detail

SimpleEventDistributorControl

public function SimpleEventDistributorControl(listenerType:Function, checkListenerType:Boolean, listeners:Array)

Constructs a new SimpleEventDistributorControl instance.

checkListenerType is by default set to true.

Parameters

listenerTypethe expected type of listeners
checkListenerTypedetermines whether to check that passed-in listeners are of the expected type
listeners(optional) the listeners to add

Throws

IllegalArgumentExceptionif the passed-in listenerType is null or undefined

Method Detail

removeAllListeners

public function removeAllListeners(Void):Void