如何订阅事件(创建主题、关闭主题等)

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.

找到它们的最佳方法是什么?我正在搜索 onAppEvent,但结果不多:

$ 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) {

我也做了一些调查,发现搜索 \.trigger\( 会列出事件实际触发的位置。