How to use the @converse/headless/utils/core.getResolveablePromise function in @converse/headless

To help you get started, we’ve selected a few @converse/headless examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conversejs / converse.js / src / headless / converse-core.js View on Github external
logout () {
            const promise = u.getResolveablePromise();
            const complete = () => {
                // Recreate all the promises
                Object.keys(_converse.promises).forEach(replacePromise);
                /**
                 * Triggered once the user has logged out.
                 * @event _converse#logout
                 */
                _converse.api.trigger('logout');
                promise.resolve();
            }

            _converse.setDisconnectionCause(_converse.LOGOUT, undefined, true);
            if (_converse.connection !== undefined) {
                _converse.api.listen.once('disconnected', () => complete());
                _converse.connection.disconnect();
            } else {
github conversejs / converse.js / src / headless / converse-core.js View on Github external
function replacePromise (name) {
    const existing_promise = _converse.promises[name];
    if (!existing_promise) {
        throw new Error(`Tried to replace non-existing promise: ${name}`);
    }
    if (existing_promise.replace) {
        const promise = u.getResolveablePromise();
        promise.replace = existing_promise.replace;
        _converse.promises[name] = promise;
    } else {
        log.debug(`Not replacing promise "${name}"`);
    }
}
github conversejs / converse.js / src / headless / converse-core.js View on Github external
promises.forEach(name => {
                const promise = u.getResolveablePromise();
                promise.replace = replace;
                _converse.promises[name] = promise;
            });
        }