Feb 8th, 2011, 04:28 AM
Why should we use EventBus when using Cairngorm
We are creating an application using the cairngorm framework. I have studied about the EventBus and came to know that it is used to establish decoupling between event publisher and event listener by using the pub/sub pattern i.e. by using this, we can assure that event publisher and event handler both are completely unknown of each other. But, if we think about the event dispatching machanism used in cairngorm framework by using "CairngormEventDispatcher.getInstace().dispatchEve nt(new eventABC())" , we found that in this case also the event publisher does not know about the event handler and vice a versa and the relation between these two is established through front controller.
So, i want to know that is it useful to use EventBus instead of CairngormEventDispatcher or it is only burden. If it is useful, and we are using EventBus, then, why should we use front controller.
Is there any sample code or any example where EventBus has been used with in Cairngorm framework.
Feb 8th, 2011, 06:44 AM
the main difference between the CairngormEventDispatcher and the EventBus is that the cairngorm dispatcher is meant specifically to map Events to Commands whereas the EventBus is more of a general event publishing/subscribing mechanism.
For instance, Spring Actionscript offers a micro-MVC system that is very similar to Cairngorm but is completely metadata driven:
So, if you´re just interested in event/command mapping, by all means use Cairngorm, even though you need to watch out that you might run into trouble when you´re application consists of multiple modules that might listen for the same events, in which case you might run into trouble.
The Spring Actionscript EventBus in v1.1 is still implemented as a singleton, version 1.2 will make use of the as3commons-eventbus which also offers event interceptors etc.