API Docs for: 1.4.0
Show:

Kiwi.SignalBinding Class

Module: Kiwi

An object that represents a binding between a Signal and a listener function.
- This is an internal constructor and shouldn't be called by regular users.
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.

Released under the MIT license http://millermedeiros.github.com/js-signals/

Constructor

Kiwi.SignalBinding

(
  • signal
  • listener
  • isOnce
  • [listenerContext]
  • [priority=0]
)
Kiwi.SignalBinding

Parameters:

  • signal Kiwi.Signal

    Reference to Signal object that listener is currently bound to.

  • listener Function

    Handler function bound to the signal.

  • isOnce Boolean

    If binding should be executed just once.

  • [listenerContext] Object optional

    Context on which listener will be executed (object that should represent the this variable inside listener function).

  • [priority=0] Number optional

    The priority level of the event listener. (default = 0).

Returns:

Methods

_destory

() public

Delete instance properties

detach

() Function | Null public

Detach this binding from the Signal it is attached to. Alias for 'Signal.remove()'

Returns:

Function | Null:

Handler function bound to the signal or null if binding was previously detached.

execute

(
  • [paramsArr]
)
public

Call listener passing arbitrary parameters. If this binding was added using Signal.addOnce() it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

Parameters:

  • [paramsArr] Array optional multiple

    Array of parameters that should be passed to the listener

Returns:

:

Value returned by the listener.

getListener

() Function public

Returns the Handler function bound to the Signal.

Returns:

Function:

Handler function bound to the signal.

getSignal

() Kiwi.Signal public

Returns the signal which this Binding is currently attached to.

Returns:

Kiwi.Signal:

Signal that listener is currently bound to.

isBound

() Boolean public

Checks to see if this Binding is still bound to a Signal and contains a listener.

Returns:

Boolean:

true if binding is still bound to the signal and have a listener.

isOnce

() Boolean public

Returns a boolean indicating whether this event will be exectued just once or not.

Returns:

Boolean:

If SignalBinding will only be executed once.

objType

() String public

The type of object that this is.

Returns:

String:

"SignalBinding"

Properties

_isOnce

Boolean private

If binding should be executed just once.

_listener

Function private

Handler function bound to the signal.

_signal

Kiwi.Signal private

Reference to Signal object that listener is currently bound to.

active

Boolean public

If binding is active and should be executed.

Default: true

context

Any public

Context on which listener will be executed (object that should represent the this variable inside listener function).

params

Any public

Default parameters passed to listener during Signal.dispatch and SignalBinding.execute. (curried parameters)

Default: null

priority

Number public

Listener priority