Event callback or stack

Monkey Forums/Monkey Programming/Event callback or stack

dmaz(Posted 2011) [#1]
Opinions.... I'm building my framework and I decided to go with an event system driven with callbacks. I'm now starting to rethink this a little as I think it might work better and more intuitively with a stack based approach. the reason is that the with callbacks the events are independent of the layering system while with stacks I would be able to stop the processing of an event on it's way down through the gfx layers (if you get my drift :) What do you think the advantages of using a callback system really are?


muddy_shoes(Posted 2011) [#2]
It depends how you've implemented the callbacks. Generally, callbacks have the advantage of being cheaper than a bubbling/hierarchical event system and the code can be simpler/more intuitive but neither is necessarily true.

There's no reason not to use both as appropriate.


dmaz(Posted 2011) [#3]
I agree... the callback system I wrote is pretty clean and easy, that's why I went that way instead of the stack. plus, I generally like processing the event without having to cycle through a stack as you implied. When you mentioned, "use both" I thought yeah why not. then I thought, wait a minute, that's going to make the whole system more complex and confusing than either. so, the challenge is to minimize that I guess. I'm not convinced if using both is the way to go but I'll give it shot.

so, other any criticisms of stack based event systems?