ig.

Signal

new Signal()

SignalsJS, a custom event broadcaster, as an Impact module.
- converted from Miller Medeiros' SignalJS - http://millermedeiros.github.com/js-signals/

Author:
  • Miller Medeiros - http://millermedeiros.github.com/js-signals/
Source:

active :boolean

If Signal is active and should broadcast events.

IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

Source:

memorize :boolean

If Signal should keep record of previously dispatched parameters and automatically execute listener during `add()`/`addOnce()` if Signal was already dispatched before.

Source:

<constant> VERSION :String

Signals Version Number

Source:

add(listener, listenerContext, priority) → {SignalBinding}

Add a listener to the signal.

Parameters:
Name Type Argument Description
listener function Signal handler function.
listenerContext Object <optional>
Context on which listener will be executed (object that should represent the `this` variable inside listener function).
priority Number <optional>
The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
Source:
Returns:
{ SignalBinding } An Object representing the binding between the Signal and listener.

addOnce(listener, listenerContext, priority) → {SignalBinding}

Add listener to the signal that should be removed after first execution (will be executed only once).

Parameters:
Name Type Argument Description
listener function Signal handler function.
listenerContext Object <optional>
Context on which listener will be executed (object that should represent the `this` variable inside listener function).
priority Number <optional>
The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
Source:
Returns:
{ SignalBinding } An Object representing the binding between the Signal and listener.

dispatch(params)

Dispatch/Broadcast Signal to all listeners added to the queue.

Parameters:
Name Type Argument Description
params * <optional>
<repeatable>
Parameters that should be passed to each handler.
Source:

dispose()

Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).

IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

Source:

forget()

Forget memorized arguments.

Source:
See:
  • Signal.memorize

getNumListeners() → {number}

Source:
Returns:
{ number } Number of listeners attached to the Signal.

halt()

Stop propagation of the event, blocking the dispatch to next listeners on the queue.

IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

Source:
See:
  • Signal.prototype.disable

has(listener, context) → {boolean}

Check if listener was attached to Signal.

Parameters:
Name Type Argument Description
listener function
context Object <optional>
Source:
Returns:
{ boolean } if Signal has the specified listener.

remove(listener, context) → {function}

Remove a single listener from the dispatch queue.

Parameters:
Name Type Argument Description
listener function Handler function that should be removed.
context Object <optional>
Execution context (since you can add the same handler multiple times if executing in a different context).
Source:
Returns:
{ function } Listener handler function.

removeAll()

Remove all listeners from the Signal.

Source:

toString() → {string}

Source:
Returns:
{ string } String representation of the object.