Converse emits events to which you can subscribe to.
The listen
namespace exposes methods for creating event listeners
(aka handlers) for these events.
Methods
(static) not(name, callback)
To stop listening to an event, you can use the not
method.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event's name |
callback |
function | The callback method that is to no longer be called when the event fires |
Example
_converse.api.listen.not('message', function (messageXML);
(static) not(name, callback)
To stop listening to an event, you can use the not
method.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event's name |
callback |
function | The callback method that is to no longer be called when the event fires |
- Source:
Example
_converse.api.listen.not('message', function (messageXML);
(static) on(name, callback, contextopt)
Lets you subscribe to an event.
Every time the event fires, the callback method specified by callback
will be called.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The event's name |
|
callback |
function | The callback method to be called when the event is emitted. |
|
context |
object |
<optional> |
The value of the |
Example
_converse.api.listen.on('message', function (messageXML) { ... });
(static) on(name, callback, contextopt)
Lets you subscribe to an event.
Every time the event fires, the callback method specified by callback
will be called.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The event's name |
|
callback |
function | The callback method to be called when the event is emitted. |
|
context |
object |
<optional> |
The value of the |
- Source:
Example
_converse.api.listen.on('message', function (messageXML) { ... });
(static) once(name, callback, contextopt)
Lets you listen to an event exactly once.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The event's name |
|
callback |
function | The callback method to be called when the event is emitted. |
|
context |
object |
<optional> |
The value of the |
Example
_converse.api.listen.once('message', function (messageXML) { ... });
(static) once(name, callback, contextopt)
Lets you listen to an event exactly once.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The event's name |
|
callback |
function | The callback method to be called when the event is emitted. |
|
context |
object |
<optional> |
The value of the |
- Source:
Example
_converse.api.listen.once('message', function (messageXML) { ... });
(static) stanza(name, options, handler)
Subscribe to an incoming stanza
Every a matched stanza is received, the callback method specified by
callback
will be called.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The stanza's name |
options |
object | Matching options (e.g. 'ns' for namespace, 'type' for stanza type, also 'id' and 'from'); |
handler |
function | The callback method to be called when the stanza appears |
(static) stanza(name, options, handler)
Subscribe to an incoming stanza
Every a matched stanza is received, the callback method specified by
callback
will be called.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The stanza's name |
options |
object | Matching options (e.g. 'ns' for namespace, 'type' for stanza type, also 'id' and 'from'); |
handler |
function | The callback method to be called when the stanza appears |
- Source: