How do I find all onAppEvents? Is there any event for color scheme switching?

In the JS API there is onAppEvent allowing to listen for an event. But how can I find the list of these events? I tried searching for onAppEvent and .trigger(, but have not found much.

Right now I am looking for an event triggering on the automatic color scheme switching (Automatic Dark Mode color scheme switching). Does such event exist?

2 Likes

You need to look for this.appEvents.trigger and this.appEvents.on
This object accessible from a handful of ember objects.

3 Likes

This specific event is handled by the browser, Discourse doesn’t have its own event here. But you can have a JS listener for the prefers-color-scheme media query. See How to detect dark mode using JavaScript (or search Google for other examples).

2 Likes