SignalCommandMap isn't triggering commands
Hiya, I've downloaded Joel Hooks' signals / robotlegs source and have made my own project in the same way. For some reason my commands aren't triggering. I've imported as3-signals-v0.5.swc robotlegs-framework-v1.0.3.swc and signals-extension-SignalsCommandMap.swc
I want my LoadXML Signal to be triggered after load, where should I dispatch this? I have tried at the end of the startup function but the mapped Command doesn't execute.
If anyone has any suggestions I'd be very grateful!
Thanks
override public function startup():void
{
trace("startup");
//map models
injector.mapSingleton(XMLService);
injector.mapSingleton(ApplicationModel);
//map signals
injector.mapSingleton(ApplicationDataLoaded);
injector.mapSingleton(XMLLoaded);
//signal command map
signalCommandMap.mapSignalClass( LoadXML, LoadXMLCommand );
signalCommandMap.mapSignalClass( XMLLoaded, XMLLoadedCommand);
signalCommandMap.mapSignalClass( ApplicationDataLoaded, SetApplicationDataCommand);
//map mediators
mediatorMap.mapView( GroupSelectorView, GroupSelectorMediator );
mediatorMap.mapView( InfoPanelView, InfoPanelMediator );
injector.mapSingleton(LoadXML);
}Comments are currently closed for this discussion. You can start a new one.
2 Posted by Abel de Beer on 08 Oct, 2010 09:51 PM
What's missing in your code is a Command that's mapped to the ContextEvent.STARTUP_COMPLETE event and the actual dispatching of the event:
`commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartupCommand);
super.startup();`
In this case the event is mapped to a Command called StartupCommand. The
supercall makes sure the complete event gets dispatched. To dispatch yourLoadXMLSignal, you can inject it into the StartupCommand and then dispatch it from the execute method.If you'd rather avoid events completely, here's an all-Signal way of running your StartupCommand:
var startup:Signal = new Signal(); signalCommandMap.mapSignal(startup, StartupCommand); startup.dispatch();Support Staff 3 Posted by Joel Hooks on 08 Oct, 2010 10:53 PM
injector.mapSingleton(LoadXML);That is going to overwrite the mapping/signal created when you mapped it to the command.
4 Posted by alistair colling on 11 Oct, 2010 08:56 AM
Thanks Joel and adeldebeer.
I didn't realise that mapping a singleton of my LoadXML signal would overwrite the assignment in thesignalCommandMap so thanks for that Joel.
I've also implemented the code suggested by abeldebeer.
For clarity and in case this is useful for anyone else I have included my code below.
Thanks again guys :)
ApplicationContext.as:
override public function startup():void
StartupCommand.as:
[Inject]
Stray closed this discussion on 13 Feb, 2011 02:58 PM.