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:

// 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.

Here is the demo and the source code.

4 Responses to “Robotlegs using a shared eventdispatcher between multiple contexts”

  1. Flash Games Says:

    Thank you..really informative!!

  2. lordB8r Says:

    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?

  3. Lorelei Koberg Says:

    Nice Infos! Interesting Article..See you soon…Have a nice Day!

  4. Herm Wong Says:


    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.

Leave a Reply