tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/415-runtime-warning-when-chaining-commands-with-the-commandsignal-extensionRobotlegs: Discussion 2011-12-08T12:23:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/110145102011-11-01T08:56:49Z2011-11-01T08:56:49ZRuntime warning when chaining Commands with the CommandSignal extension<div><p>Hi Will,</p>
<p>It could mean your SignalCommandMap is out of date - it was
leaving mappings lying around some time ago.</p>
<p>Or - if you're definitely up to date, then it might be something
you can ignore - it won't actually change the action, it just
reports if it thinks something funny is going on. It all depends
how your Signals are being chained - whether the next signal is
firing before the mappings for the first have been cleaned up.</p>
<p>Sx</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/110145102011-11-01T12:03:17Z2011-11-01T12:03:17ZRuntime warning when chaining Commands with the CommandSignal extension<div><p>Thanks Stray. I'm definitely using the latest versions of
both.</p>
<p>I've had a look at the source of SignalCommandMap and I think I
understand what's happening. Technically the warning is correct in
the case I've mentioned above because the signal's payload is
mapped to the injector just before execute is called and then
unmapped immediately afterwards.... as it should. The issue here is
that we are triggering a second command INSIDE the first command's
execute method and the triggering signal's payload is mapped BEFORE
the first command's payload is unmapped... so thus there is a
double-up in the injector. Again this is only an issue when both
commands require an injection of the same type.</p>
<p>A quick-and-dirty solution I've found is to modify the
SignalCommandMap to expose the injector. Then, inside my first
command I forcibly unmap that command's injections before
triggering my next command. This stops the warning.</p>
<p>I'm wondering if there is a more elegant solution to this which
doesn't require modifying SignalCommandMap. I've noticed the
vanilla Command class get's access to the injector but from what I
can tell there is no way to get access to the child injector used
by SignalCommandMap. I think either exposing the child injector in
SignalCommandMap OR injecting the injector automatically into
SignalCommand could be a solution.</p>
<p>I realise this is 'just a warning' and the code continues to
execute properly I just think If it could be avoided altogether
that would stop a lot of confusion.</p>
<p>Stray I'd love to hear your thoughts on this :)</p></div>willdadytag:robotlegs.tenderapp.com,2009-10-18:Comment/110145102011-11-04T11:53:35Z2011-11-04T11:53:35ZRuntime warning when chaining Commands with the CommandSignal extension<div><p>Hi Will,</p>
<p>I'm not sure it's possible to fix it generically - it's just a
reality that the mapping can't be unmapped by the map until the
command has executed. If you squeeze another mapping in to that
process then the mapping may have to be overwritten.</p>
<p>The purpose of the warning is only to 'warn' you. In most cases,
overwriting a mapping means that you made a mistake. In this case
it doesn't - so, the warning is still sensible in my view.</p>
<p>The child injector is the one used to instantiate the Command,
so if you just inject IInjector then the one injected will be the
child injector of the SCM - so you can do that part easily.</p>
<p>hth!</p>
<p>Stray</p></div>Stray