Class: Signal

system.signals. Signal


new Signal()

Creates a new Signal instance.

Implements:
Example
function Slot( name )
{
    this.name = name ;
}

Slot.prototype = Object.create( system.signals.Receiver.prototype );
Slot.prototype.constructor = Slot;

Slot.prototype.receive = function ( message )
{
    trace( this + " : " + message ) ;
}

Slot.prototype.toString = function ()
{
    return "[Slot name:" + this.name + "]" ;
}

var slot1 = new Slot("slot1") ;

var slot2 = function( message )
{
    trace( this + " : " + message ) ;
}

var signal = new system.signals.Signal() ;

//signal.proxy = slot1 ;

signal.connect( slot1 , 0 ) ;
signal.connect( slot2 , 2 ) ;

signal.emit( "hello world" ) ;

Members


<readonly> length :number

The number of receivers or slots register in the signal object.

Type:
  • number
Default Value:
  • 0

proxy :Object

The proxy reference of the signal to change the scope of the slot (function invoked when the signal emit a message).

Type:
  • Object
Default Value:
  • null

Methods


connect(receiver [, priority] [, autoDisconnect])

Connects a Function or a Receiver object.

Parameters:
Name Type Argument Default Description
receiver system.signals.Receiver | function

The receiver to connect : a Function reference or a Receiver object.

priority number <optional>
0

Determinates the priority level of the receiver.

autoDisconnect boolean <optional>
false

Apply a disconnect after the first trigger

Returns:

true If the receiver is connected with the signal emitter.

Type
boolean

connected()

Returns true if one or more receivers are connected.

Returns:

true if one or more receivers are connected.

Type
boolean

disconnect(receiver)

Disconnect the specified object or all objects if the parameter is null.

Parameters:
Name Type Description
receiver system.signals.Receiver | function

The receiver to disconnect : a Function reference or a Receiver object.

Returns:

true if the specified receiver exist and can be unregister.

Type
boolean

emit(values)

Emit the specified values to the receivers.

Parameters:
Name Type Description
values *

All values to emit to the receivers.


hasReceiver()

Returns true if the specified receiver is connected.

Returns:

true if the specified receiver is connected.

Type
boolean

toArray()

Returns the Array representation of all receivers connected with the signal.

Returns:

The Array representation of all receivers connected with the signal.

Type
array

toString()

Returns the string representation of this instance.

Returns:

the string representation of this instance.

Type
string