tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/335-nativemappedsignal-and-parameters-inside-a-commandRobotlegs: Discussion 2018-10-18T16:35:28Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T14:44:11Z2011-06-21T14:44:11ZNativeMappedSignal and parameters inside a Command<div><p>Hi all,</p>
<p>Today I came across a situation where I have a
NativeMappedSignal hooked up to a command. Inside this command I
want to have access to the event that was dispatched. Unfortunately
the event is not automatically injected, so I can use it inside my
command. I've been looking into this for a couple of hours already,
but so far without any success. So I was hoping anyone else here
came across the same needs and has a solution for this.</p>
<p>Thanks in advance!</p>
<p>Paul</p></div>Paultag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T15:27:06Z2011-06-21T15:27:06ZNativeMappedSignal and parameters inside a Command<div><p>what are you using to map the signal to the command?</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T15:45:16Z2011-06-21T15:45:16ZNativeMappedSignal and parameters inside a Command<div><p>For example:</p>
<p>var someClick:NativeMappedSignal = new
NativeMappedSignal(contextView, MouseEvent.CLICK);<br>
signalCommandMap.mapSignal(someClick, SomeClickCommand);</p>
<p>If this was my case, I would have liked to inject the MouseEvent
within my "SomeClickCommand"</p></div>Paultag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T16:29:25Z2011-06-21T16:29:59ZNativeMappedSignal and parameters inside a Command<div><p>OK, I think this is because you are using the
NativeMappedSignal, not the NativeSignal.</p>
<p>What the SignalCommandMap does is to map the signals value
objects into the command (well its associated child injector).</p>
<p>The NativemappedSignal allows you to map different values other
than the Event to the signals value objects</p>
<p>So in a nutshell, the ValueObject of a NativeMappedSignal is not
the Event, its the value(s) that you have mapped to it</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T16:51:22Z2011-06-21T16:51:24ZNativeMappedSignal and parameters inside a Command<div><p>First of all thanks for your quick replies Neil!</p>
<p>I've tried using NativeSignal as well, that threw an error so I
moved on trying the other Native*Signals.</p>
<p>The error I'm getting is "Exception fault: ArgumentError:
Listener for native event must declare exactly 1 argument."</p>
<p>This happens immediately after mapping the signal to a command.
It seems like a callback method needs to implement just one
argument. No more and no less. Looking at the SignalCommandMap, I
see that a callback method with 6 arguments is defined. So am I
missing something on the implementation side, or is a nativeSignal
not ready to hook up with a command yet?</p>
<p>Paul</p></div>Paultag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T17:59:56Z2011-06-21T17:59:56ZNativeMappedSignal and parameters inside a Command<div><p>then it would seem that NativeSignal and SignalCommandMap need
to sit down and talk things over a bit.</p>
<p>what value(s) do you want from the event?</p>
<p>you could use the NativeMappedSignal to map those values to its
ValueObjects, then they will be injected into the Command</p>
<p>or if it is the event you want, then you can probably map
that.</p>
<p>Don't know if you have seen this:</p>
<p><a href=
"http://j0hn.org/videos//NativeMappedSignal.mp4">http://j0hn.org/videos//NativeMappedSignal.mp4</a></p>
<p>but john lindquist does an excellent job as usual walking
through the NativeMappedSignal</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-21T21:09:16Z2011-06-21T21:09:18ZNativeMappedSignal and parameters inside a Command<div><p>I think that NativeSignal and SignalCommandMap indeed need to
talk with each other.</p>
<p>The resource you pointed me to by John Lindquist is quite
helpful in terms that I now understand when to use one or the
other. Unfortunately your help did not solve my issue. I tried
returning the event, or wrapping the information that I need into a
VO, but that VO can't be injected in my controller.</p>
<p>I've a workaround where I somewhere in my application just
listen to the event and then map the event manually, run the
command and unmap the event again. This is not as elegant as it
could be, but it works as a pragmatical solution.</p>
<p>I'll have a look at GitHub and file this as an issue with
NativeSignal/SignalCommandMap.</p>
<p>Anyhow, thanks for all your feedback. It helped a lot while
getting a better understanding of this problem!</p></div>Paultag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-22T09:09:40Z2011-06-22T09:09:42ZNativeMappedSignal and parameters inside a Command<div><p>Strange. Theoretically it should work. If I ever have the time I
will do some tests.</p></div>neilmanuelltag:robotlegs.tenderapp.com,2009-10-18:Comment/80778532011-06-22T09:19:06Z2011-06-22T09:19:08ZNativeMappedSignal and parameters inside a Command<div><p>BTW, if you write a test to prove it, you could create an issue
on the rl githib rep.</p></div>neilmanuell