Converse converse.js

Namespace: promises

_converse.api.promises

Converse and its plugins trigger various events which you can listen to via the _converse.api.listen namespace.

Some of these events are also available as ES2015 Promises although not all of them could logically act as promises, since some events might be fired multpile times whereas promises are to be resolved (or rejected) only once.

Events which are also promises include:

The various plugins might also provide promises, and they do this by using the promises.add api method.

Source:

Methods

(static) add(name|namesopt, replaceopt)

By calling promises.add, a new Promise is made available for other code or plugins to depend on via the _converse.api.waitUntil method.

Generally, it's the responsibility of the plugin which adds the promise to also resolve it.

This is done by calling _converse.api.trigger, which not only resolves the promise, but also emits an event with the same name (which can be listened to via _converse.api.listen).

Parameters:
Name Type Attributes Default Description
name|names string | array <optional>

The name or an array of names for the promise(s) to be added

replace boolean <optional>
true

Whether this promise should be replaced with a new one when the user logs out.

Source:
Example
_converse.api.promises.add('foo-completed');

(static) add(name|namesopt, replaceopt)

By calling promises.add, a new Promise is made available for other code or plugins to depend on via the _converse.api.waitUntil method.

Generally, it's the responsibility of the plugin which adds the promise to also resolve it.

This is done by calling _converse.api.trigger, which not only resolves the promise, but also emits an event with the same name (which can be listened to via _converse.api.listen).

Parameters:
Name Type Attributes Default Description
name|names string | array <optional>

The name or an array of names for the promise(s) to be added

replace boolean <optional>
true

Whether this promise should be replaced with a new one when the user logs out.

Source:
Example
_converse.api.promises.add('foo-completed');

_converse.api.promises

Converse and its plugins trigger various events which you can listen to via the _converse.api.listen namespace.

Some of these events are also available as ES2015 Promises although not all of them could logically act as promises, since some events might be fired multpile times whereas promises are to be resolved (or rejected) only once.

Events which are also promises include:

The various plugins might also provide promises, and they do this by using the promises.add api method.

Source:

Methods

(static) add(name|namesopt, replaceopt)

By calling promises.add, a new Promise is made available for other code or plugins to depend on via the _converse.api.waitUntil method.

Generally, it's the responsibility of the plugin which adds the promise to also resolve it.

This is done by calling _converse.api.trigger, which not only resolves the promise, but also emits an event with the same name (which can be listened to via _converse.api.listen).

Parameters:
Name Type Attributes Default Description
name|names string | array <optional>

The name or an array of names for the promise(s) to be added

replace boolean <optional>
true

Whether this promise should be replaced with a new one when the user logs out.

Source:
Example
_converse.api.promises.add('foo-completed');

(static) add(name|namesopt, replaceopt)

By calling promises.add, a new Promise is made available for other code or plugins to depend on via the _converse.api.waitUntil method.

Generally, it's the responsibility of the plugin which adds the promise to also resolve it.

This is done by calling _converse.api.trigger, which not only resolves the promise, but also emits an event with the same name (which can be listened to via _converse.api.listen).

Parameters:
Name Type Attributes Default Description
name|names string | array <optional>

The name or an array of names for the promise(s) to be added

replace boolean <optional>
true

Whether this promise should be replaced with a new one when the user logs out.

Source:
Example
_converse.api.promises.add('foo-completed');