EventListenerSource
TypeSafeEventListenerSource manages listeners in a type-safe manner.
public function TypeSafeEventListenerSource(listenerType:Function, checkListenerType:Boolean)
Constructs a new TypeSafeEventListenerSource 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 |
| IllegalArgumentException | if the passed-in listenerType is
null or undefined
|
public function getListenerType(Void):FunctionReturns the expected listener type.
the expected listener type
public function isListenerTypeChecked(Void):BooleanReturns whether a listener's type is checked up on the expected listener type.
true a listener's type is checked else false
public function addListener(listener):Void
Adds the passed-in listener.
The listener will only be added if it is neither null nor
undefined and if it is of the expected listener type specified on
construction and if it has not already been added to this listener source.
Note that the listener type will not be checked if it was turned of on construction.
listener | the listener to add |
| IllegalArgumentException | if the passed-in listener is not of the
expected type specified on construction
|
public function addAllListeners(listeners:Array):Void
Adds all listeners contained in the passed-in listeners array.
If the passed-in listeners array is null or undefined
it will be ignored.
The individual listeners must be instances of the type specified on
construction. If an individual listener is null or undefined it
will be ignored.
All listeners that are of the correct type will be added.
Note that the listener type will not be checked if it was turned of on construction.
Note also that the order of the listeners contained in the passed-in
listeners array is preserved.
listeners | the listeners to add |
| IllegalArgumentException | if at least one listener in the passed-in
listeners array is not of the expected type specified on construction
|
addAllListeners() in org.as2lib.env.event.EventListenerSource
public function removeListener(listener):Void
Removes the passed-in listener.
The removal will be ignored if the passed-in listener is null
or undefined.
listener | the listener to remove |
removeListener() in org.as2lib.env.event.EventListenerSource
public function removeAllListeners(Void):VoidRemoves all added listeners.
removeAllListeners() in org.as2lib.env.event.EventListenerSource
public function getAllListeners(Void):ArrayReturns all added listeners that are of the type specified on construction.
all added listeners
getAllListeners() in org.as2lib.env.event.EventListenerSource