How do I handle priority and propagation in an event system?
https://softwareengineering.stackexchange.com/questions/140743
-
04-11-2019 - |
Question
Let's say I have a simple event system with the following syntax:
object = new Object();
object.bind("my_trigger", function() { print "hello"; });
object.bind("my_trigger", function() { print "hello2"; });
object.trigger("my_trigger");
How could I make sure hello2 is printed out first? (I do not want my code to depend on which order the events were bind).
On top of that, how would I prevent my events from propagating? (e.g. I want to stop every other event from being executed)
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with softwareengineering.stackexchange