Class: Phaser.SignalBinding


new SignalBinding(signal, listener, isOnce, listenerContext, priority, args)

Object that represents a binding between a Signal and a listener function.
This is an internal constructor and shouldn't be created directly.
Inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.

Name Type Argument Default Description
signal Phaser.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 number <optional>

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

args any <optional>

Additional arguments to pass to the callback (listener) function. They will be appended after any arguments usually dispatched.

Source code: core/SignalBinding.js (Line 22)

Public Properties

active : boolean

If binding is active and should be executed.

Default Value
  • true
Source code: core/SignalBinding.js (Line 93)

callCount : number

The number of times the handler function has been called.

Source code: core/SignalBinding.js (Line 86)

context : Object

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

Source code: core/SignalBinding.js (Line 63)

params :array | null

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

  • array | null
Source code: core/SignalBinding.js (Line 100)

Public Methods

detach() → {function | null}

Detach binding from signal.
alias to: @see mySignal.remove(myBinding.getListener());

function | null -

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

Source code: core/SignalBinding.js (Line 136)

execute(paramsArr) → {any}

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

Name Type Argument Description
paramsArr Array.<any> <optional>

Array of parameters that should be passed to the listener.

any -

Value returned by the listener.

Source code: core/SignalBinding.js (Line 102)

getListener() → {function}

function -

Handler function bound to the signal.

Source code: core/SignalBinding.js (Line 162)

getSignal() → {Phaser.Signal}


Signal that listener is currently bound to.

Source code: core/SignalBinding.js (Line 170)

isBound() → {boolean}

boolean -

True if binding is still bound to the signal and has a listener.

Source code: core/SignalBinding.js (Line 146)

isOnce() → {boolean}

boolean -

If SignalBinding will only be executed once.

Source code: core/SignalBinding.js (Line 154)

toString() → {string}

string -

String representation of the object.

Source code: core/SignalBinding.js (Line 189)

© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.