Day 34

August 17, 2017 16:08 UTC Team berlin diamonds (Discourse) [2017]Subscribe to this teams's activities


Checked a very old tutorial on how to use EventMachine in hope to understand events. Nothing worked, the APIs were not online anymore and I couldn't follow up in the console. I ended up having the same feeling as when I started.

Loved the choice for the Covenant code of conduct Kaja made!

Looked into changing how our backup plugins hook into the main app, using an Event instead a class_eval :

Dived into the galaxy of Discourse's code looking for all the DiscourseEvent.trigger and its correspondent DiscourseEvent.on and understood that EventDiscourse.trigger takes at least one argument, which is the name of the Event created. Then EventDiscoure.on takes the same argument (same symbol name), and that's how they connect between each other. The .on (listener) is like a light that's switched on and that contains a block of code. The .trigger (placed where you want to execute the listener code) detects that light .on and executes the block of code there.

Created a DiscourseEvent.trigger(:backupcreated) in the Backup model and sent a PR to Discourse. Now backup plugins can hook into the app through a listener: DiscourseEvent.on(:backupcreated) instead overwriting the aftercreatehook method in the model through class_eval.


You must be logged in to add a comment.