ConsumableEventMulticaster
SimpleConsumableEventMulticaster multicasts an event to all added listeners with
custom arguments until the event is consumed.
Example:
// creates a multicaster for the 'onError' event
var multicaster:SimpleConsumableEventMulticaster = new SimpleConsumableEventMulticaster("onError");
// adds listeners
multicaster.addListener(new SimpleErrorListener());
multicaster.addListener(new MyErrorListener());
// executes the specified event on all listeners passing the given arguments
multicaster.dispatch(myErrorCode, myException);
The event dispatch is stopped as soon as any of the above listeners returns
true. If for example the SimpleErrorListener.onError method
returns true, MyErrorListener.onError will not be executed
because the event is consumed.
public function SimpleConsumableEventMulticaster(eventName:String, listeners:Array)
Constructs a new SimpleConsumableEventMulticaster instance.
eventName | the name of the event to execute on listeners |
listeners | (optional) an array of listeners to populate this broadcaster with |
| IllegalArgumentException | if passed-in eventName is null,
undefined or an empty string
|
public function getEventName(Void):StringReturns the event name set on construction.
the name of the event
public function dispatch():Void
Dispatches the event to all listeners passing the given arguments as parameters
to the listeners' event methods until a listener consumes the event by returning
true.
... | any number of arguments to pass to the listeners' event methods |
| EventExecutionException | if a listener's event method threw an exception |