tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/201-modules-inside-modulesRobotlegs: Discussion 2018-10-18T16:35:19Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/36599262010-11-05T14:54:42Z2010-11-05T14:54:42ZModules inside Modules<div><p>Hi Enrique,</p>
<p>Nothing is truly "global" in Robotlegs. Feel free to bend the modular utils to suit your needs - it simply comes down to sharing plain old IEventDispatcher instances and using them how you see fit.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/36599262010-11-05T15:00:01Z2010-11-05T15:00:01ZModules inside Modules<div><p>Absolutely.</p>
<p>There's no reason not to just create and share a ParentEventDispatcher and ParentCommandMap etc. You could just extend the existing Module ones and weave it in.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/36599262010-11-05T23:01:58Z2010-11-05T23:02:00ZModules inside Modules<div><p>OK, so there's no any "native" solution for the moment.<br />
I thought 3 possible solutions:<br />
Situation:<br />
Application has many "windows" modules.<br />
And each window has modules too.</p>
<p>1) Create 2 more dispatcher in each Module, we will have 3 dispatchers then:<br />
eventDispatcher = self communication<br />
parentDispatcher = sends/receives messages to the parent module<br />
childDispatcher = sends/receives messages to the childs modules<br />
The childDispatcher of the parent Module is equal to the parentDispatcher of the current Module.<br />
And we must redispatch each Event if we want to reach a deeper level (it's like bubbling)<br />
We could have a 4th dispatcher: globalDispatcher for reaching every module in any level (=moduleDispatcher)</p>
<p>CONS: we must change all classes of Modular Utilities and maybe it's a performance killer with so much dispatchers...</p>
<p>2) Create a new class, based on a new interface IIsolator. This class has 3 dispatchers:<br />
eventDispatcher = self communication<br />
outsideDispatcher = sends/receive messages outside this module (parents in any level)<br />
innerDispatcher = sends/receive messages inside this module (childs in any level)<br />
So if we want for example our windows to receive events from other windows and the shell etc, but NOT from the modules inside other windows, we can make our Window implements IIsolator.<br />
In that situation:<br />
outsideDispatcher = shell.moduleDispatcher;<br />
insideDispatcher = new moduleDispatcher;<br />
childs.moduleDispatcher = insideDispatcher; //childs maybe need a new Injector.</p>
<p>PROS: we don't need to change Modular Utilities, just extend it.<br />
CONS: it scares me.</p>
<p>3) Each module must be a View for its parent and a Mediator for its childs.</p>
<p>CONS: we can only dispatch outside our module from the MainView if we want to dispatch to our parents (because the parent mediator is listening that view), or from our Mediators if we want to dispatch to our childModules.<br />
And if this is not the actual option for modular applications I'm sure that's because it has a lot of problems.</p>
<p>I don't like my options and I don't feel secure with any of them :(<br />
Maybe you can help me to find a solution. You are a lot smarter and more experienced than me.</p>
<p>Thanks!</p></div>Enrique