tag:robotlegs.tenderapp.com,2009-10-18:/discussions/suggestions/23-combined-use-of-signalcontext-and-modulecontextRobotlegs: Discussion 2018-10-18T16:35:12Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T22:26:14Z2010-06-01T22:26:14Zcombined use of SignalContext and ModuleContext<div><p>I do :)</p>
<p>I simply hacked my module context to be a
ModuleSignalContext.</p>
<p>It's no more sophisticated than:</p>
<p>public class ModuleContext extends SignalContext implements
IModuleContext</p>
<p>We talked about some sort of boot strapping / decorator thing
for special contexts, but for now the roll-your-own approach is so
easy that it's not a big deal.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T22:34:02Z2010-06-01T22:34:02Zcombined use of SignalContext and ModuleContext<div><p>what a stupid question of mine :) thanks a lot.</p></div>tomtag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T22:40:52Z2010-06-01T22:40:52Zcombined use of SignalContext and ModuleContext<div><p>This is where inheritance breaks. Oh to have Scala's Traits.</p>
<p>ModuleContext is the more complex of the two. Essentially you
just need to merge the two. SignalContext is pretty straight
forward.</p>
<p>Totally not a stupid question!</p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T22:43:17Z2010-06-01T22:43:17Zcombined use of SignalContext and ModuleContext<div><p>No - it's fair to assume that it would be harder than that -
Robotlegs usually surprises me by being simpler than I'd
imagined!</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T23:00:04Z2010-06-01T23:00:04Zcombined use of SignalContext and ModuleContext<div><p>thanks. i'm confused though - did you change the source of
ModuleContext in robotlegs-utilities-Modular or adjusted your
project's context? in the latter case my commands are not triggered
by the mapped signals.</p></div>tomtag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T23:04:34Z2010-06-01T23:04:34Zcombined use of SignalContext and ModuleContext<div><p>I changed the source of ModuleContext in the modular utils
library itself.</p>
<p>Ugly but effective.</p>
<p>It's one reason why I like to have source and not just swc for
my libs!</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T23:15:43Z2010-06-01T23:17:01Zcombined use of SignalContext and ModuleContext<div><p><a href=
"http://gist.github.com/421669">http://gist.github.com/421669</a></p>
<p>Your context would likely look like this.</p>
<p>I recommend not monkey patching libraries unless it is actually
necessary and a new cleaner base isn't an option :></p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T23:38:48Z2010-06-01T23:38:48Zcombined use of SignalContext and ModuleContext<div><p>thanks a lot, compiles fine.</p>
<p>i guess i have an additional problem:</p>
<p><code>commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE,
StartupCommand, ContextEvent, true);</code></p>
<p>StartupCommand emits a signal which is mapped to a command</p>
<p><code>signalCommandMap.mapSignalClass(LoadModuleSignal,
LoadModuleCommand);</code></p>
<p>LoadModuleCommand is not getting executed. maybe it's too early
to do so - the main class' applicationComplete event is triggered
after the StartupCommand has been executed.</p></div>tomtag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-01T23:48:20Z2010-06-01T23:48:20Zcombined use of SignalContext and ModuleContext<div><p>so, mapping the signal returns the signal instance. Are you
using that?</p>
<pre>
var signal:LoadModuleSignal = signalCommandMap.mapSignalClass(LoadModuleSignal,
LoadModuleCommand) as LoadModuleSignal;
signal.dispatch();
</pre></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-02T00:16:14Z2010-06-02T00:18:32Zcombined use of SignalContext and ModuleContext<div><p>great, it's working. did i fail to read the documentation? doh.
anyway, thank you very much.</p>
<p>err - now i've run into another problem.</p>
<p><code>Error: Injector is missing a rule to handle injection into
target [object ModuleReadyCommand]. Target dependency:
org.robotlegs.utilities.modular.core::IModule</code></p>
<p>ModuleReadyCommand is mapped to ModuleReadySignal</p>
<pre>
<code> signalCommandMap.mapSignalClass(ModuleReadySignal, ModuleReadyCommand);</code>
</pre>
<p>the signal's constructor calls super<br></p>
<pre>
<code> super(IModule);</code>
</pre>
<p>finally, the command requests injection</p>
<pre>
<code> [Inject]
public var module : IModule;</code>
</pre>
<p>reminds me of the ArrayCollection issue but i guess i'm doing
something wrong, again.</p></div>tomtag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-02T14:26:17Z2010-06-02T14:26:17Zcombined use of SignalContext and ModuleContext<div><p>this issue keeps bothering me. shall i open a seperate post?</p></div>tomtag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302010-06-02T19:31:49Z2010-06-02T19:31:51Zcombined use of SignalContext and ModuleContext<div><p>Tom,</p>
<p>I kept running into similar issues a couple of weeks ago.
Looking at Modular RL, most of the code seemed around sharing
dispatchers between modules. Since we're using Signals exclusively
for application-level communication, I ignored all that and rolled
a simple modular context. I think this is a (considerably)
different approach, but it works for me so far. As far as I can
tell from looking at Modular RL source, I don't think I'm missing
any non-Event-related functionality.</p>
<p>I found a RL bug in the process and <a href=
"http://github.com/deafbybeheading/robotlegs-examples-ConfigurableModules">
wrote a simple example app</a> to try to hunt it down. The app
includes my modular context. It also allows for distinct
configuration state for each module instance, something that I
needed in my actual app.</p>
<p>Note that my app doesn't use real Flex modules (just modular
pieces of the application), but I think it can be extended to use
Flex modules without changes to the context.</p></div>Maciektag:robotlegs.tenderapp.com,2009-10-18:Comment/18299302011-01-31T10:41:04Z2011-01-31T10:41:04Zcombined use of SignalContext and ModuleContext<div><p>Awesome code Joel :)</p></div>Nikos