Packageorg.osflash.signals
Classpublic class MonoSignal
InheritanceMonoSignal Inheritance Object
Implements ISignal

A MonoSignal can have only one listener.

Default MXML PropertyvalueClasses



Public Properties
 PropertyDefined By
  numListeners : uint
[read-only] The current number of listeners for the signal.
MonoSignal
  valueClasses : Array
An optional array of classes defining the types of parameters sent to listeners.
MonoSignal
Protected Properties
 PropertyDefined By
  slot : Slot
MonoSignal
  _valueClasses : Array
MonoSignal
Public Methods
 MethodDefined By
  
MonoSignal(... valueClasses)
Creates a MonoSignal instance to dispatch value objects.
MonoSignal
  
add(listener:Function):ISlot
Subscribes a listener for the signal.
MonoSignal
  
addOnce(listener:Function):ISlot
Subscribes a one-time listener for this signal.
MonoSignal
  
dispatch(... valueObjects):void
Dispatches an object to listeners.
MonoSignal
  
remove(listener:Function):ISlot
Unsubscribes a listener from the signal.
MonoSignal
  
removeAll():void
Unsubscribes all listeners from the signal.
MonoSignal
Protected Methods
 MethodDefined By
  
registerListener(listener:Function, once:Boolean = false):ISlot
MonoSignal
Property Detail
_valueClassesproperty
protected var _valueClasses:Array

numListenersproperty 
numListeners:uint  [read-only]

The current number of listeners for the signal.


Implementation
    public function get numListeners():uint
slotproperty 
protected var slot:Slot

valueClassesproperty 
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

Throws
ArgumentError ArgumentError: Invalid valueClasses argument: item at index should be a Class but was not.
Constructor Detail
MonoSignal()Constructor
public function MonoSignal(... valueClasses)

Creates a MonoSignal instance to dispatch value objects.

Parameters
... valueClasses — Any number of class references that enable type checks in dispatch(). For example, new Signal(String, uint) would allow: signal.dispatch("the Answer", 42) but not: signal.dispatch(true, 42.5) nor: signal.dispatch() NOTE: Subclasses cannot call super.apply(null, valueClasses), but this constructor has logic to support super(valueClasses).
Method Detail
add()method
public function add(listener:Function):ISlot

Subscribes a listener for the signal.

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 add or addOnce with a listener already added, remove the current listener first.
 
ArgumentError ArgumentError: Given listener is null.
addOnce()method 
public function addOnce(listener:Function):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 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 add or addOnce with a listener already added, remove the current listener first.
 
ArgumentError ArgumentError: Given listener is 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.


Throws
ArgumentError ArgumentError: Incorrect number of arguments.
 
ArgumentError ArgumentError: Value object is not an instance of the appropriate valueClasses Class.
registerListener()method 
protected function registerListener(listener:Function, once:Boolean = false):ISlot

Parameters

listener:Function
 
once:Boolean (default = false)

Returns
ISlot
remove()method 
public function remove(listener:Function):ISlot

Unsubscribes a listener from the signal.

Parameters

listener:Function

Returns
ISlot — a ISlot, which contains the Function passed as the parameter
removeAll()method 
public function removeAll():void

Unsubscribes all listeners from the signal.