Class org.as2lib.env.event.distributor.SimpleConsumableEventDistributorControl

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

Implemented Interfaces

ConsumableEventDistributorControl

Description

SimpleConsumableEventDistributorControl acts as a listener source and event distributor. It enables you to distribute and handle events in the safest way possible.

Note that unlike the SimpleEventDistributorControl class, this class supports the consumption of events. An event is consumed if an event method on a listener returns true. This means that the distribution of the event will be stopped immediately. Otherwise the event will further be distributed.

Example: // creates a distributor control with the expected listener type var distributorControl:SimpleConsumableEventDistributorControl = new SimpleConsumableEventDistributorControl(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);

If in the above example, the MyErrorListener.onError method returns true, the SimpleErrorListener.onError method will not be invoked because the event is consumed.

Method Index

new SimpleConsumableEventDistributorControl()

Inherited from AbstractEventDistributorControl

getDistributor(), getType()

Inherited from TypeSafeEventListenerSource

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

Inherited from BasicClass

toString()

Constructor Detail

SimpleConsumableEventDistributorControl

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

Constructs a new SimpleConsumableEventDistributorControl 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