Class: SignalBinding

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.

Parameters:
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>
null

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>
<repeatable>
(none)

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

Source:
src/core/SignalBinding.js line 22

Members

active : boolean

If binding is active and should be executed.

Type:
  • boolean
Default Value:
  • true
Source:
src/core/SignalBinding.js line 92

callCount : number

The number of times the handler function has been called.

Type:
  • number
Source:
src/core/SignalBinding.js line 85

context : object

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

Type:
  • object
Source:
src/core/SignalBinding.js line 62

params : array | null

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

Type:
  • array | null
Source:
src/core/SignalBinding.js line 99

Methods

detach()

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

Source:
src/core/SignalBinding.js line 134
Returns:

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

Type
function | null

execute( [paramsArr])

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.

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

Array of parameters that should be passed to the listener.

Source:
src/core/SignalBinding.js line 101
Returns:

Value returned by the listener.

Type
any

getListener()

Source:
src/core/SignalBinding.js line 163
Returns:

Handler function bound to the signal.

Type
function

getSignal()

Source:
src/core/SignalBinding.js line 172
Returns:

Signal that listener is currently bound to.

Type
Phaser.Signal

isBound()

Source:
src/core/SignalBinding.js line 145
Returns:

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

Type
boolean

isOnce()

Source:
src/core/SignalBinding.js line 154
Returns:

If SignalBinding will only be executed once.

Type
boolean

toString()

Source:
src/core/SignalBinding.js line 193
Returns:

String representation of the object.

Type
string

phaser-ce@2.20.1 is on GitHub and NPM

Documentation generated by JSDoc 3.6.11 on 2024-10-05 using Tomorrow.