My previous post demonstrated modular programming in the Robotlegs framework using the Robotlegs modular utilities. This post will discuss a workaround that I came up with to handle inter-context communication between modules before the Robotlegs Modular Utilities were released.
The benefits of using this workaround is that you can have modules in their own encapsulated contexts, the disadvantage is that this solution is not very scalable if you have lots of events that need to be mapped between the contexts.
The basic idea is to create a getter for the _eventDispatcher property in the context of each module. Once the root application has fired the creationComplete event, the handler for creationComplete needs to use the getters so that the root application can perform the necessary event mapping which will allow the two modules to communicate.
I’ve added inline comments within the source code explaining how to map the events between the modules.