Constructor
new core/Messenger(idopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
any |
<optional> |
Id for the object. If none is provided a new id will |
Properties:
Name | Type | Description |
---|---|---|
GlobalMessenger |
core/Messenger | A messenger that can be used for |
EVENTS |
Object | Built-in events that the Messenger emits. |
Members
(readonly) id :string
Gets the string id of the object.
Type:
- string
Methods
(static) emit(message, valueopt)
Send a message, causing listener functions for the message on the global Messenger
instance to be executed.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | The message to emit. |
|
value |
any |
<optional> |
Optional argument to pass to listener callbacks. |
(static) listenTo(message, callback)
Execute a function when a message is received for the global Messenger instance.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | The message to listen for. |
callback |
function | Function to execute once the message is received. |
(static) stopListening(message, callbackopt)
Prevent a function from being executed when a message is received for the
global Messenger instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | The message to stop listening for. |
|
callback |
function |
<optional> |
Optional callback to remove. If none is defined, |
(static) stopListeningByRegexp(regexp, callbackopt)
De-register callback(s) from being executed on the global messengerr instance
when messages matching the given regular expression are received.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
regexp |
Regexp | regexp - The regular expression to filter messages with. |
|
callback |
function |
<optional> |
Optional callback to remove. If none is defined, |
(static) stopListeningToAll()
Prevent any functions from being executed when any message is received for
the global Messenger instance.
emit(message, valueopt)
Send a message, causing listener functions for the message on this object
to be executed.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | The message to emit. |
|
value |
any |
<optional> |
Optional argument to pass to listener callbacks. |
listenTo(message, callback)
Execute a function when a message is received for this object.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | The message to listen for. |
callback |
function | Function to execute once the message is received. |
stopListening(message, callbackopt)
Prevent a function from being executed when a message is received for this
object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | The message to stop listening for. |
|
callback |
function |
<optional> |
Optional callback to remove. If none is defined, |
stopListeningByRegexp(regexp, callbackopt)
De-register callback(s) from being executed when messages matching the given
regular expression are received.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
regexp |
Regexp | regexp - The regular expression to filter messages with. |
|
callback |
function |
<optional> |
Optional callback to remove. If none is defined, |
stopListeningToAll()
Prevent any functions from being executed when any message is received for
this object.