Class: Signal

PIXI.Signal

new PIXI.Signal ()

MiniSignal constructor.

Example

 let mySignal = new Signal();
 let binding = mySignal.add(onSignal);
 mySignal.dispatch('foo', 'bar');
 mySignal.detach(binding);

Methods

add (fn, thisArg) PIXI.SignalBinding

Register a new listener.

Name Type Attributes Description
fn Function

Callback function.

thisArg object <optional>

The context of the callback function.

Returns:
Type Description
PIXI.SignalBinding The SignalBinding node that was added.

detach (node) Signal

Remove binding object.

Name Type Description
node PIXI.SignalBinding

The binding node that will be removed.

Returns:
Type Description
Signal The instance on which this method was called.

detachAll () Signal

Detach all listeners.

Returns:
Type Description
Signal The instance on which this method was called.

dispatch (…args) Boolean

Dispaches a signal to all registered listeners.

Name Type Description
args any[]
Returns:
Type Description
Boolean Indication if we've emitted an event.

handlers (exists) Array<PIXI.SignalBinding> | Boolean

Return an array of attached SignalBinding.

Name Type Attributes Default Description
exists Boolean <optional>
false

We only need to know if there are handlers.

Returns:
Type Description
Array<PIXI.SignalBinding> | Boolean Array of attached SignalBinding or Boolean if called with exists = true

has (node) Boolean

Return true if node is a SignalBinding attached to this MiniSignal

Name Type Description
node PIXI.SignalBinding

Node to check.

Returns:
Type Description
Boolean True if node is attache to mini-signal

once (fn, thisArg) PIXI.SignalBinding

Register a new listener that will be executed only once.

Name Type Attributes Description
fn Function

Callback function.

thisArg object <optional>

The context of the callback function.

Returns:
Type Description
PIXI.SignalBinding The SignalBinding node that was added.