tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/831-modularityRobotlegs: Discussion 2013-02-19T11:31:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-17T11:53:52Z2013-02-17T11:53:52ZModularity .. ?<div><p>Hi Gustavo,</p>
<p>First questions:<br>
What is the role of that Module?<br>
Is the ‘Manager’ some kind of a Service class,
accessing external resources? Are there more ‘Managers’
inside your Module, and you’re trying to access the right
one, depending on some conditions?</p>
<p>Why don’t you use events to communicate with your Module?
Say, the shell or other modules dispatch
SomeModularEvent.USER_DATA_NEEDED to access UserService,<br>
SomeModularEvent.LAYOUT_DATA_NEEDED to access LayoutService and so
on. The results would be sent back to the shell or other modules
via an event’s payload, SomeModularEvent.USER_DATA_LOADED,
SomeModularEvent.LAYOUT_DATA_LOADED</p>
<p>Most probably I didn’t understand your use case, so please
try to explain it better :)<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-18T08:35:18Z2013-02-18T08:35:18ZModularity .. ?<div><p>Hello Ondina,</p>
<p>The Module is a Service, I have other services that work
correctly though and that are working through Event's communication
as you described. I could make this module work the same way... non
the less I still remain puzzled, and don't quite get how the
Manager can not be registered to 2 contexts without passing the
shell context to the module to work over it.</p>
<p>For example, my module manager works like a remote-control,
offering public function to play, stop and pause the animation of
the module. I could , like you suggested, make it work with
event's... but can I also make the manager use internally the
modules context and injector, while the shell has the Manager
mapped on it's own injector? That is basically what I've been
wondering the whole time.</p>
<p>Thank you for your reply :)</p></div>Gustavotag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-18T12:04:43Z2013-02-18T12:04:43ZModularity .. ?<div><p>Module implementing ISomeModule:</p>
<p>function getModuleService():IModuleService<br>
return injector.getOrCreateNewInstance(IModuleService);</p>
<p>Shell:</p>
<p>moduleService=(moduleLoader.child as
ISomeModule).getModuleService();</p>
<p>Since you got an instance already, you should map it like
this:</p>
<p>injector.map(IModuleService).toValue(moduleService);</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-18T12:27:10Z2013-02-18T12:28:40ZModularity .. ?<div><p>OHHHHHHHHHH!!!!</p>
<p>I got it !!!!</p>
<p>It was, as usual, Human mistake!... And that human, was ME !</p>
<p>Now, this is what I was trying to do.... I mapped the same Class
Manager as a Singleton ion both the Shell and the module, and the
tried to override the Singleton created by the shell with the one
retrieved by the module thus a simple '=' operator.</p>
<pre>
<code>[inject]
var shellManagerSingleTon :Manager;
...
shellManagerSingleTon = moduleRetrievedSingleton.</code>
</pre>
<p>And naturally, this did not worked on all other places where the
Manager was Injected.</p>
<p>Then I changed this:</p>
<pre>
<code>shellManagerSingleTon = moduleRetrievedSingleton.</code>
</pre>
<p>with this:</p>
<pre>
<code>injector.map(Manager).toValue(moduleRetrievedSingleton);</code>
</pre>
<p>and Presto! all is now working nice and dandy!</p>
<p>I will anyhow refactor it to work via Signals... but my mind is
in peace to understand what the problem was.</p>
<p>:)</p></div>Gustavotag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-18T12:27:49Z2013-02-18T12:27:49ZModularity .. ?<div><p>YESSSS!!</p>
<p>I now see your response!</p>
<p>That was the way to do it ;)</p>
<p>Thank you Ondina</p></div>Gustavotag:robotlegs.tenderapp.com,2009-10-18:Comment/250027582013-02-18T12:31:20Z2013-02-18T12:31:20ZModularity .. ?<div><p>You're welcome, Gustavo :)</p></div>Ondina D.F.