GODPAPER | All Packages | All Classes | Index | Frames No Frames |
Signal

Package | org.osflash.signals
Class | public class Signal
Inheritance | Signal OnceSignal Object
Implements | ISignal
Subclasses | NativeRelaySignal, PrioritySignal

Signal dispatches events to multiple listeners. It is inspired by C# events and delegates, and by signals and slots in Qt. A Signal adds event dispatching functionality through composition and interfaces, rather than inheriting from a dispatcher. Project home: http://github.com/robertpenner/as3-signals/

Default MXML Property `valueClasses`

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | numListeners : uint [read-only] The current number of listeners for the signal. | OnceSignal
|  | valueClasses : Array An optional array of classes defining the types of parameters sent to listeners. | OnceSignal

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | slots : SlotList | OnceSignal
|  | _valueClasses : Array | OnceSignal

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | Signal(... valueClasses) Creates a Signal instance to dispatch value objects. | Signal
|  | add(listener:Function):ISlot Subscribes a listener for the signal. | Signal
|  | addOnce(listener:Function):ISlot Subscribes a one-time listener for this signal. | OnceSignal
|  | dispatch(... valueObjects):void Dispatches an object to listeners. | OnceSignal
|  | remove(listener:Function):ISlot Unsubscribes a listener from the signal. | OnceSignal
|  | removeAll():void Unsubscribes all listeners from the signal. | OnceSignal

Protected Methods
Show Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | registerListener(listener:Function, once:Boolean = false):ISlot | OnceSignal
|  | registrationPossible(listener:Function, once:Boolean):Boolean | OnceSignal

Constructor Detail

Signal | () | Constructor

`public function Signal(... valueClasses)`

Creates a Signal 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: In AS3, 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 addOnce() then add() the same listener without removing the relationship first.
| `ArgumentError` — `ArgumentError`: Given listener is `null`.

Thu Jan 16 2014, 01:11 PM +08:00