org.as2lib.env.event.distributor.AbstractCompositeEventDistributorControl
CompositeEventDistributorControl
AbstractCompositeEventDistributorControl
is the default implementation
of the CompositeEventDistributorControl
interface.
To use its functionalities, simply extend it and set a factory for the default event distributors.
new AbstractCompositeEventDistributorControl()
public function AbstractCompositeEventDistributorControl(eventDistributorControlFactory:EventDistributorControlFactory)
Creates a new AbstractCompositeEventDistributorControl
instance.
eventDistributorControlFactory | the factory to create event distributor controls for the different listener types |
public function addListener(l):Void
Adds a the given listener to this event distributor control.
It validates if the passed-in listener
is of any of the accepted
listener types.
The listener will be added to all matching distributors.
l | the Listener to add to the control |
IllegalArgumentException | if the given listener does not match any of the accepted types. |
public function removeListener(l):Void
Removes the given listener from this distributor control and thus from listening to events.
l | the listener to remove |
public function addAllListeners(listeners:Array):Void
Adds a list of listeners to this event distributor control to listen to events.
listeners | the list of listeners to add |
IllegalArgumentException | if any listener is not accepted (the listeners before the certain listener will be added) |
public function getAllListeners(Void):Array
Returns a list that contains all listeners.
the list that contains all listeners
public function hasListener(l):Boolean
Checks if the given listener has already been added.
l | the listener to check whether it has already been added |
true
if the listener has been added
public function acceptListenerType(listenerType:Function):Void
Adds acception for the given listenerType
.
addListener
does not allow listeners that do not match (instanceof)
at least one of the accepted listener types.
acceptListenerType() in org.as2lib.env.event.distributor.CompositeEventDistributorControl
public function getDistributor(type:Function)
Returns the distributor that can be used to broadcast an event to all added listeners that match the distributor's type.
Note that the returned distributor will not be updated if you add a new
distributor control for the given type
after you obtained a distributor.
You must get a new distributor if you want an updated one.
the distributor to distribute events
IllegalArgumentException | if there is no distributor for the given
type
|
getDistributor() in org.as2lib.env.event.distributor.CompositeEventDistributorControl
public function registerEventDistributorControl(eventDistributorControl:EventDistributorControl):Void
Registers the given eventDistributorControl
with its listener and
distributor type returned by its EventDistributorControl.getType method.
The type is then automatically an accepted listener type.
If there is already a distributor control registered for the given type, it will be overwritten.
If you hold references to distributors of this type, returned by the getDistributor method, you will have to update them, else events will not be distributed to newly registered listeners of that type.
You use this method if you have a specific event that should be executed with a special kind of distributor, for example with a consumable one.
eventDistributorControl | the event distributor control to use for event distribution for the given type |
IllegalArgumentException | if the given argument eventDistributorControl
is null or undefined
|
registerEventDistributorControl() in org.as2lib.env.event.distributor.CompositeEventDistributorControl
public function registerDefaultEventDistributorControl(type:Function):Void
Registers a default event distributor control with the given listener and
distributor type
.
The type
is then automatically an accepted listener type.
If there is already a distributor control registered for the given type, it will be overwritten.
type | the type to register a default distributor control with |
IllegalArgumentException | if argument type is null or
undefined
|
registerDefaultEventDistributorControl() in org.as2lib.env.event.distributor.CompositeEventDistributorControl