Discourse is a modern javascript application ![]()
The best way is to use the message-bus library. Currently it does depend on JQuery, but if you would like to submit a pull request to remove that dependency, I’m sure it would be considered.
Messagebus is only intended to be used within Discourse, it’s not really a ‘public’ API. The best source of information will be the javascript files in the codebase, which you already found ![]()