I am currently creating a plugin and was wondering how to subscribe to different events.
initializePlugin() exposes an api object that has the function onAppEvent(name, fn).
Is there a list somewhere with the name of the events one can subscribe to?
Your best shot at an up-to-date list is to grep the source code for these events.
j127
Août 1, 2019, 11:45
3
Quelle est la meilleure méthode pour les trouver ? Je cherche onAppEvent, mais cela ne donne pas grand-chose :
$ grep -r onAppEvent *
app/assets/javascripts/discourse/lib/plugin-api.js.es6: this.onAppEvent("page:changed", data => fn(data.url, data.title));
app/assets/javascripts/discourse/lib/plugin-api.js.es6: api.onAppEvent('inserted-custom-html', () => {
app/assets/javascripts/discourse/lib/plugin-api.js.es6: onAppEvent(name, fn) {
jsapp/lib/plugin-api.js.es6: this.onAppEvent("page:changed", data => fn(data.url, data.title));
jsapp/lib/plugin-api.js.es6: api.onAppEvent('inserted-custom-html', () => {
jsapp/lib/plugin-api.js.es6: onAppEvent(name, fn) {
phallguy
(Paul Alexander)
Septembre 20, 2019, 8:33
4
J’ai également fait quelques recherches et j’ai découvert que la recherche de \.trigger\( produisait une liste des endroits où les événements sont réellement déclenchés.