How do I handle priority and propagation in an event system?
Posted
by
Peeter
on Programmers
See other posts from Programmers
or by Peeter
Published on 2012-03-20T21:54:53Z
Indexed on
2012/03/20
23:39 UTC
Read the original article
Hit count: 314
Lets 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 are binded).
Ontop of that, how would I prevent my events from propagating (e.g. I want to stop every other event from being executed)
© Programmers or respective owner