A quick one about Signals / RL integration
Hi all,
First of all thanks a lot to the people who did all the hard work, RL is the first framework I use in production (outside of customized MVC ones) and I have to say the more I use it, the more I like it.
But there's still something I don't get. I'm trying to map a Signal to a Command. So in the context (a SignalContext), I've got :
signalCommandMap.mapSignalClass(FullscreenRequested, ToggleFullscreen);
Inside a mediator (that mediates a button), I've added a reference to inject:
[Inject] public var fsEvent:FullscreenRequested;
Then inside a click event:
fsEvent.dispatch();
Pretty easy. I was then thinking that the command should be
triggered, but it's not! I can see a trace in the click event but
the command is neither fired nor even created. Any ideas?
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 mike.cann on 04 Jun, 2010 12:38 PM
Hi Stef,
I assume fsEvent isnt null as that would cause a null reference when you try to call dispatch. That means that it is getting the wrong instance from somewhere.
Are you mapping a singleton to FullscreenRequested too?
Mike
2 Posted by stf on 04 Jun, 2010 12:51 PM
Yeah I did actually, inside the context (otherwise I would have had missing injection error):
injector.mapSingleton(FullscreenRequested);
Sorry forgot to mention it.
3 Posted by mike.cann on 04 Jun, 2010 01:00 PM
Ah, well im not sure what is going on with your missing injection but if you are mapping a signal to a command you shouldnt map a singleton too, that will cause a problem.
Mike
4 Posted by stf on 04 Jun, 2010 01:15 PM
Okay I removed the singleton in the context, so the only thing related to that Signal is the mapping to the Command:
signalCommandMap.mapSignalClass(FullscreenRequested, ToggleFullscreen);
I tried to create an instance of the Signal in the mediator:
private var fsEvent:FullscreenRequested;
then dispatch it. But once again, the mapping just doesnt work. Any ideas for a workaround to handle that?
5 Posted by mike.cann on 04 Jun, 2010 01:19 PM
Did you mean private:
private var fsEvent:FullscreenRequested;
As this wont be recognised by the injector if you want it to be injected it must be public and decorated with [Inject] so:
[Inject] public var fsEvent:FullscreenRequested;
Mike
Support Staff 6 Posted by Shaun Smith on 04 Jun, 2010 01:20 PM
I'm not too familiar with the SignalCommandMap, but I do know that Joel just released a bugfix (yesterday). Are you running the latest versions of RL (v1.1.0 beta8) and SignalCommandMap?
Support Staff 7 Posted by Joel Hooks on 04 Jun, 2010 03:03 PM
This is related to the bugfix from yesterday related to RL1.1 and the SignalCommandMap utility. My apologies for this. The utility now has a unit test to cover this scenario ;)
http://github.com/joelhooks/signals-extensions-CommandSignal/commit...
Joel Hooks closed this discussion on 04 Jun, 2010 03:03 PM.
stf re-opened this discussion on 05 Jun, 2010 10:06 PM
8 Posted by stf on 05 Jun, 2010 10:06 PM
Wow that a was a perfect timing^^ I tested it and it works. Thanks!
9 Posted by stf on 10 Jun, 2010 01:23 PM
Got a similar problem now, inside a model proxy:
The context links an Signal class to a Command:
signalCommandMap.mapSignalClass(BufferManagerEvent, BufferManager);
Then inside the model proxy:
[Inject] public var buffermanagerEvent:BufferManagerEvent; buffermanagerEvent.dispatch();
I'm using lots of Signals in that class (around 15), and they are all dispatched and catched by views for example. But this one is the only one that's related to a Command in the context (others are mapped as singletons). The Command is never fired, and no errors are returned.
10 Posted by stf on 14 Jun, 2010 09:36 AM
Just to make the post going up - anyone got any idea on that? The problem is pretty simple I guess, but I can't make it work!
Stray closed this discussion on 10 Feb, 2011 05:27 PM.