problem listening for signals in mediator using signalMap
Hi guys,
Just got into robotlegs about a week ago and it's pretty great. The examples really helped me out. I've got events working great and since I used AS3 Signals before robotlegs I figured I might as well get it going here.
Using Joel Hooks' Signal Command map I have gotten to the point , that works where you create a Signal class like ApplicationXMLSignal:
import org.osflash.signals.ISignal;
import org.osflash.signals.Signal;
public class ApplicationXMLSignal extends Signal
{
public function ApplicationXMLSignal()
{
super(XML);
}
}
Map it to a command:
public class PrepControllerCommand extends SignalCommand
{
override public function execute():void
{
signalCommandMap.mapSignalClass(ApplicationXMLSignal, UpdateModelFromXmlSignalCommand, true);
}
}
Write the command the signal is mapped to:
package com.rad.control.commands.model
{
import com.demonsters.debugger.MonsterDebugger;
import com.rad.model.ApplicationModel;
import org.robotlegs.mvcs.SignalCommand;
public class UpdateModelFromXmlSignalCommand extends SignalCommand
{
[Inject]
public var appModel:ApplicationModel;
[Inject]
public var xml:XML;
override public function execute() : void
{
MonsterDebugger.trace(this, xml);
if(appModel.xml)
{
appModel.xml = xml;
}
}
}
}
So how do you listen for signals in mediators?
I got Stray's signalMap add-on from Here.
When I try and add a listener using the signalMap in a mediator
class extending SignalMediator, I get this error:
1067: Implicit coercion of a value of type Class to an
unrelated type org.osflash.signals:ISignal
I thought I could just listen for my signal that I wrote earlier (top of post ). Why is it asking for ISignal? What is an ISignal? Any help would be appreciated, this is the missing piece for me!
Thanks,
Sam
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 Abel de Beer on 17 Feb, 2012 10:50 AM
You're probably doing something like
signalMap.addToSignal(ApplicationXMLSignal, myHandler)
in your mediator, right? The problem is that addToSignal expects an instance of ISignal, the interface that Signal implements, while you are giving it a class, ApplicationXMLSignal.What you could do is first inject the signal into your mediator and then map it:
Note that the signal can only be injected once it has been mapped to the Injector, or through the SignalCommandMap.
2 Posted by eggbeer on 17 Feb, 2012 04:37 PM
Nice one man. That worked a charm! In case someone else is interested, you have to extend
SignalMediator
instead ofMediator
.eggbeer closed this discussion on 17 Feb, 2012 04:37 PM.