The NativeSignal class provides a strongly-typed facade for an IEventDispatcher.
A NativeSignal is essentially a mini-dispatcher locked to a specific event type and class.
It can become part of an interface.
The object considered the source of the dispatched events.
Implementation public function get target():IEventDispatcher public function set target(value:IEventDispatcher):void
valueClasses
property
valueClasses:Array
An optional array of classes defining the types of parameters sent to listeners.
Implementation public function get valueClasses():Array public function set valueClasses(value:Array):void
Constructor Detail
NativeSignal
()
Constructor
public function NativeSignal(target:IEventDispatcher = null, eventType:String, eventClass:Class = null)
Creates a NativeSignal instance to dispatch events on behalf of a target object.
Parameters
target:IEventDispatcher (default = null) — The object on whose behalf the signal is dispatching events.
eventType:String — The type of Event permitted to be dispatched from this signal. Corresponds to Event.type.
eventClass:Class (default = null) — An optional class reference that enables an event type check in dispatch(). Defaults to flash.events.Event if omitted.
listener:Function — A function with arguments
that matches the value classes dispatched by the signal.
If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.
Returns
ISlot — a ISlot, which contains the Function passed as the parameter
Throws
flash.errors:IllegalOperationError — IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
ArgumentError — ArgumentError: Given listener is null.
ArgumentError — ArgumentError: Target object cannot be null.
Subscribes a one-time listener for this signal.
The signal will remove the listener automatically the first time it is called,
after the dispatch to all listeners is complete.
Parameters
listener:Function — A function with arguments
that matches the value classes dispatched by the signal.
If value classes are not specified (e.g. via Signal constructor), dispatch() can be called without arguments.
Returns
ISlot — a ISlot, which contains the Function passed as the parameter
Throws
flash.errors:IllegalOperationError — IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
ArgumentError — ArgumentError: Given listener is null.
ArgumentError — ArgumentError: Target object cannot be null.
addOnceWithPriority
()
method
public function addOnceWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a one-time listener for this signal.
The signal will remove the listener automatically the first time it is called,
after the dispatch to all listeners is complete.
Parameters
listener:Function — A function with an argument
that matches the type of event dispatched by the signal.
If eventClass is not specified, the listener and dispatch() can be called without an argument.
priority:int (default = 0) — The priority level of the event listener.
The priority is designated by a signed 32-bit integer.
The higher the number, the higher the priority.
All listeners with priority n are processed before listeners of priority n-1.
Returns
ISlot — a ISlot, which contains the Function passed as the parameter
Throws
flash.errors:IllegalOperationError — IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
ArgumentError — ArgumentError: Given listener is null.
ArgumentError — ArgumentError: Target object cannot be null.
addWithPriority
()
method
public function addWithPriority(listener:Function, priority:int = 0):ISlot
Subscribes a listener for the signal.
After you successfully register an event listener,
you cannot change its priority through additional calls to add().
To change a listener's priority, you must first call remove().
Then you can register the listener again with the new priority level.
Parameters
listener:Function — A function with an argument
that matches the type of event dispatched by the signal.
If eventClass is not specified, the listener and dispatch() can be called without an argument.
priority:int (default = 0)
Returns
ISlot — a ISlot, which contains the Function passed as the parameter
Throws
flash.errors:IllegalOperationError — IllegalOperationError: You cannot addOnce() then add() the same listener without removing the relationship first.
ArgumentError — ArgumentError: Given listener is null.
ArgumentError — ArgumentError: Target object cannot be null.
dispatch
()
method
public function dispatch(... valueObjects):void
Dispatches an object to listeners.
Parameters
... valueObjects — Any number of parameters to send to listeners. Will be type-checked against valueClasses.