Aug 29
My last couple posts discussed two different methods of writing modular applications using the Robotlegs framework. This post will demonstrate yet another method of writing modular applications in Robotlegs using a shared eventDispatcher between the modules.
This approach requires the creation of a getter method for the eventDispatcher from the Application Shell’s context. The eventDispatcher is then injected into the contexts of each module using:
1 2 | // injects the application shell's eventDispatcher into the module's context injector.mapValue(EventDispatcher, Application.application.applicationEventDispatcher, "ApplicationEventDispatcher"); |
The “ApplicationEventDispatcher” is then used to listen to events and to dispatch events throughout the entire application.
August 29th, 2010 at 19:38
Thank you..really informative!!
August 29th, 2010 at 20:01
perhaps I don’t fully understand all of robotlegs yet, but your code seems awfully verbose just to generate a timestamp. Is all of robotlegs this cumbersome in setup?
August 30th, 2010 at 2:22
Nice Infos! Interesting Article..See you soon…Have a nice Day!
August 30th, 2010 at 6:46
@lordB8r:
The timestamp generation application is just a silly example to demonstrate how to use a shared application eventDispatcher between the Robotlegs contexts. In typical Robotlegs applications each context has its own eventDispatcher which is only scoped to work within its own context. This example demonstrates a work around where you can inject the application context’s eventDispatcher into the contexts of the different modules so that they can use the application context’s eventDispatcher to communicate between the modules and application shell.