Add an app event for when a topic is fully loaded

Add an app event for when a topic is fully loaded

If we are interested in page events (say analytics), they are reported when the route changes, which does not wait for any promises in setupController to finish.

A plugin might want to know when a topic has fully loaded, so this event is triggered when that happens.

diff --git a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6 b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6
index 70f5640..c193cbe 100644
--- a/app/assets/javascripts/discourse/routes/topic-from-params.js.es6
+++ b/app/assets/javascripts/discourse/routes/topic-from-params.js.es6
@@ -52,6 +52,7 @@ export default Discourse.Route.extend({
           enteredAt: new Date().getTime().toString()
         });
 
+        this.appEvents.trigger("page:topic-loaded", topic);
         topicController.subscribe();
 
         // Highlight our post after the next render

GitHub sha: 847f48a9

1 Like