NativeMappedSignal and parameters inside a Command
Hi all,
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.
Thanks in advance!
Paul
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by neil on 21 Jun, 2011 03:27 PM
what are you using to map the signal to the command?
2 Posted by Paul on 21 Jun, 2011 03:45 PM
For example:
var someClick:NativeMappedSignal = new NativeMappedSignal(contextView, MouseEvent.CLICK);
signalCommandMap.mapSignal(someClick, SomeClickCommand);
If this was my case, I would have liked to inject the MouseEvent within my "SomeClickCommand"
3 Posted by neil on 21 Jun, 2011 04:29 PM
OK, I think this is because you are using the NativeMappedSignal, not the NativeSignal.
What the SignalCommandMap does is to map the signals value objects into the command (well its associated child injector).
The NativemappedSignal allows you to map different values other than the Event to the signals value objects
So in a nutshell, the ValueObject of a NativeMappedSignal is not the Event, its the value(s) that you have mapped to it
4 Posted by Paul on 21 Jun, 2011 04:51 PM
First of all thanks for your quick replies Neil!
I've tried using NativeSignal as well, that threw an error so I moved on trying the other Native*Signals.
The error I'm getting is "Exception fault: ArgumentError: Listener for native event must declare exactly 1 argument."
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?
Paul
5 Posted by neil on 21 Jun, 2011 05:59 PM
then it would seem that NativeSignal and SignalCommandMap need to sit down and talk things over a bit.
what value(s) do you want from the event?
you could use the NativeMappedSignal to map those values to its ValueObjects, then they will be injected into the Command
or if it is the event you want, then you can probably map that.
Don't know if you have seen this:
http://j0hn.org/videos//NativeMappedSignal.mp4
but john lindquist does an excellent job as usual walking through the NativeMappedSignal
6 Posted by Paul on 21 Jun, 2011 09:09 PM
I think that NativeSignal and SignalCommandMap indeed need to talk with each other.
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.
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.
I'll have a look at GitHub and file this as an issue with NativeSignal/SignalCommandMap.
Anyhow, thanks for all your feedback. It helped a lot while getting a better understanding of this problem!
7 Posted by neilmanuell on 22 Jun, 2011 09:09 AM
Strange. Theoretically it should work. If I ever have the time I will do some tests.
8 Posted by neilmanuell on 22 Jun, 2011 09:19 AM
BTW, if you write a test to prove it, you could create an issue on the rl githib rep.
Ondina D.F. closed this discussion on 01 Nov, 2011 04:11 PM.