Commit e12c1654 authored by JC Brand's avatar JC Brand

Add new event `pluginsInitialized` and use it in converse-notifications

By listening for this event before registering event handlers, other plugins
can first get their overrides of those handlers applied.
parent 73bf2f88
......@@ -912,6 +912,8 @@ Once converse.js has been initialized.
``converse.listen.on('initialized', function (event) { ... });``
See also `pluginsInitialized`_.
messageSend
~~~~~~~~~~~
......@@ -926,6 +928,17 @@ When keepalive=true but there aren't any stored prebind tokens.
``converse.listen.on('noResumeableSession', function (event) { ... });``
pluginsInitialized
~~~~~~~~~~~~~~~~~~
Once all plugins have been initialized. This is a useful event if you want to
register event handlers but would like your own handlers to be overridable by
plugins. In that case, you need to first wait until all plugins have been
initialized, so that their overrides are active. One example where this is used
is in [converse-notifications.js](https://github.com/jcbrand/converse.js/blob/master/src/converse-notification.js).
``converse.listen.on('pluginsInitialized', function (event) { ... });``
reconnected
~~~~~~~~~~~
......
......@@ -1786,6 +1786,7 @@
'updateSettings': updateSettings,
'converse': converse
});
converse.emit('pluginsInitialized');
converse._initialize();
converse.registerGlobalEventHandlers();
return init_deferred.promise();
......
......@@ -243,11 +243,16 @@
}
};
converse.on('contactRequest', converse.handleContactRequestNotification);
converse.on('contactStatusChanged', converse.handleChatStateNotification);
converse.on('message', converse.handleMessageNotification);
converse.on('feedback', converse.handleFeedback);
converse.on('connected', converse.requestPermission);
converse.on('pluginsInitialized', function () {
// We only register event handlers after all plugins are
// registered, because other plugins might override some of our
// handlers.
converse.on('contactRequest', converse.handleContactRequestNotification);
converse.on('contactStatusChanged', converse.handleChatStateNotification);
converse.on('message', converse.handleMessageNotification);
converse.on('feedback', converse.handleFeedback);
converse.on('connected', converse.requestPermission);
});
}
});
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment