Members
destroyed :Boolean
This read-only property shows whether this Messenger is destroyed.
Properties:
Name | Type | Description |
---|---|---|
destroyed |
- Default Value:
- false
- Source:
Type:
-
Boolean
Methods
(static) initialize(object)
Call this method in an Object's instantiation if Messenger.mixin
has been called on its Class.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
object |
Object
|
The object for which Messenger should be instantiated. |
(static) mixin(ClassObject)
Adds Messenger functionality to a Class.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
ClassObject |
Class
|
function
|
The class to add Messenger behavior to. |
getMessageIds() → {Array}
This method returns all the messages that this entity is concerned about.
- Source:
Returns:
- Type:
-
Array
An array of strings listing all the messages for which this Messenger has handlers.
off(name, callback)
Remove the event listener
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event; if no name is specifed remove all listeners. |
callback |
function
|
The listener function. |
on(name, callback)
Add an event listener. The parameters for the listener functions depend on the event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event. |
callback |
function
|
The callback function when event is triggered. |
toString()
Returns a string describing the Messenger as "[Messenger object]".
- Source:
Returns:
String
trigger(event, value, debug) → {number}
This method is used by both internal components and external entities to trigger messages. When triggered, Messenger checks through bound handlers to run as appropriate. This handles multiple event structures: "", [], and {}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
String
|
Array
|
Object
|
This is the message(s) to process. This can be a string, an object containing an "event" property (and optionally a "message" property, overriding the value below), or an array of the same. |
value |
*
|
This is a message object or other value to pass along to event handler. |
debug |
boolean
|
This flags whether to output message contents and subscriber information to the console during game development. A "value" object parameter (above) will also set this flag if value.debug is set to true. |
Returns:
- Type:
-
number
The number of handlers for the triggered message.
triggerEvent(event, valueopt) → {number}
This method is used by both internal components and external entities to trigger messages on this entity. When triggered, entity checks through bound handlers to run as appropriate. This method is identical to Spring Roll's EventDispatcher.trigger, but uses alternative Array methods to alleviate excessive GC.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
event |
String
|
This is the message to process. |
|||||||||
value |
*
|
<optional> |
This is a message object or other value to pass along to event handler.
|
Returns:
- Type:
-
number
The number of handlers for the triggered message.