Constructor
new L3D.Signal(name)
name |
String |
""
|
Optional name for the signal, usually used for debugging purposes. |
Properties
Returns true if signals are allowed to be emitted. If false, calling the Signal's emit method will do nothing.
True if this signal has at least one listener.
Methods
static disable()
Disables all signals from being emitted. This can be called multiple times, but an equal number of calls to enable should be used to re-enable signals. This is often used to disable any callbacks while doing heavy operations, like file loading, so a single signal will be emitted at the end.
static disconnect(object, callback, instance)
Disconnect the listener from all signals of the given object.
object |
Object | The object to disconnect from. |
|
callback |
function | Signal | Object | The listener to disconnect |
|
instance |
Object |
null
|
The optional listener instance that owns callback. |
static enable(force)
Enable signals to be emitted, having been previously disabled.
force |
bool |
false
|
If true, signals will be forced to the enabled state, even if there were an unbalanced number of calls to disable.. |
static getSignals(object, out) → Array
Return all signals that belong to the object.
object |
Object | The object to get the signals from. |
out |
Array | Optional storage for the results. A new array will be created if null. |
- Array
The list of signals that belong to the object.
addListener(callback, object)
Connect a listener to the signal. This can be a function, object method, class static method, or another signal. There is no type-checking to ensure the listener function can successfully receive the arguments that will be emitted by the signal, which will result in an exception of you connect an incompatible listener and emit the signal. To have an object method listen to a signal, pass in the object, too.
listen(Function)
listen(Signal)
listen(method, object)
callback |
function | Signal | ||
object |
Object |
null
|
disconnect(callback, object)
Disconnect a listener from the signal.
disconnect(Object) -- Disconnect all method listeners of the given object.
disconnect(Function) -- Disconnect the function listener.
disconnect(Signal) -- Disconnect the signal listener.
disconnect(method, object) -- Disconnect the method listener.
disconnect() -- Disconnect all listeners from the signal.
callback |
* | |
object |
Object |
emit(…arguments)
Emit a signal, calling all listeners.
arguments* |
* | Optional arguments to call the listeners with. |
isListening(callback, object) → bool
Checks if there is a binded listener that matches the criteria.
isListening(Signal)
isListening(callback)
isListening(object)
isListening(method, object)
callback |
function | Signal | Object | ||
object |
Object |
null
|
- bool