## Index

- File Index
- Class Index
- Symbol Index

## Classes

- _global_
- Signal
- SignalBinding
- signals

### Class

- Signal

### Fields

- active
- memorize
- VERSION

### Methods

- add
- addOnce
- dispatch
- dispose
- forget
- getNumListeners
- halt
- has
- remove
- removeAll
- toString

# Class Signal

Defined in: signals.js.

Class Detail
Signal()

Custom event broadcaster
- inspired by Robert Penner's AS3 Signals.

Author: Miller Medeiros.
Field Detail
{boolean} active

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.

{boolean} memorize

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

{String} VERSION

Signals Version Number

Method Detail
{SignalBinding} add(listener, listenerContext, priority)

Add a listener to the signal.

Parameters:
{Function} listener
  Signal handler function.
{Object} listenerContext Optional
  Context on which listener will be executed (object that should represent the `this` variable inside listener function).
{Number} priority 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)

Returns:
  {SignalBinding} An Object representing the binding between the Signal and listener.

{SignalBinding} addOnce(listener, listenerContext, priority)

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

Parameters:
{Function} listener
  Signal handler function.
{Object} listenerContext Optional
  Context on which listener will be executed (object that should represent the `this` variable inside listener function).
{Number} priority 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)

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:
{...*} params Optional
  Parameters that should be passed to each handler.

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.

forget()

Forget memorized arguments.

See:
  Signal.memorize

{number} getNumListeners()

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.

See:
  Signal.prototype.disable

{boolean} has(listener, context)

Check if listener was attached to Signal.

Parameters:
{Function} listener
{Object} context Optional

Returns:
  {boolean} if Signal has the specified listener.

{Function} remove(listener, context)

Remove a single listener from the dispatch queue.

Parameters:
{Function} listener
  Handler function that should be removed.
{Object} context Optional
  Execution context (since you can add the same handler multiple times if executing in a different context).

Returns:
  {Function} Listener handler function.

removeAll()

Remove all listeners from the Signal.

{string} toString()

Returns:
  {string} String representation of the object.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Nov 29 2012 17:48:56 GMT-0200 (BRST) | template based on Steffen Siering jsdoc-simple.