Issue with signalCommandMap
Can someone advise me on this error:
Error: Injector is missing a rule to handle injection into target [object ApplicationMediator]. Target dependency: views.signalz::ApplicationUserChanged
I have a context doing this
signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);
so I feel I should not get the error for this code:
[Inject]
public var applicationUserChanged : ApplicationUserChanged;
The code for the mediator is like this:
package views
{
import events.UserEvent;
import flash.events.Event;
import model.UserModel;
import model.vo.User;
import org.robotlegs.mvcs.Mediator;
import views.signalz.ApplicationUserChanged;
public class ApplicationMediator extends Mediator
{
[Inject]
public var applicationUserChanged : ApplicationUserChanged;
[Inject]
public var view:PR_SUITE;
[Inject]
public var userModel:UserModel;
override public function onRegister():void
{
eventMap.mapListener(eventDispatcher,UserEvent.USER_LOGIN, handleLogin);
userModel.usersArrived.add(handleUsersArrived);
view.applicationUserChanged.add(handleApplicationUserChanged);
}
protected function handleApplicationUserChanged(user:User):void
{
applicationUserChanged.dispatch(user);
}
protected function handleUsersArrived():void
{
view.users.dataProvider = userModel.userList;
}
protected function handleLogin(event:Event):void
{
view.currentState = PR_SUITE.COMMENTS_VIEW;
}
}
}
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 Stray on 15 Nov, 2010 05:32 PM
Hi Nikos,
basically, if the signal hasn't fired it won't yet exist as a singleton to be injected.
So - to inject into mediators is something like this in your context (or where you are doing mapSignalClass):
var applicationUserChangedSignal:ApplicationUserChanged = new ApplicationUserChanged();
signalCommandMap.mapSignal(applicationUserChangedSignal, GetSelectedApplicationUserDataCommand);
But you might want to check some more examples.
I can't quite remember whether you need to map that signal as a singleton and then do get instance, or whether you just map the value as a singleton, or whether the SCM takes care of it all... but that's the gist.
Stray
2 Posted by ZackPierce on 15 Nov, 2010 05:55 PM
I don't think this is the case. The contents of
SignalCommandMap#mapSignalClass
are:getSignalClassInstance
typically leads tocreateSignalClassInstance
, which is responsible for creating and mapping signals.So, the
mapSignalClass
call is already instantiating the appropriate signal (if necessary), and mapping it as a singleton.Nikos, does your Context change the Injector instance mapped to the IInjector class? I ask because the
SignalCommandMap
generates and maps its signal-singletons using an IInjector instance obtained by callinginjector.getInstance(IInjector);
, where the firstinjector
there is the SignalCommandMap's internal IInjector, which is added at SignalCommandMap instantiation.3 Posted by Nikos on 15 Nov, 2010 06:00 PM
thanks guys, my context is doing this
All my other signals get injected fine into my mediators
package
{
}
4 Posted by Stray on 15 Nov, 2010 06:11 PM
Hi Zack,
I'm sure you're right - my fork of SignalCommandMap that I use is old and pre childInjector stuff.
Thanks,
Stray
5 Posted by ZackPierce on 15 Nov, 2010 06:20 PM
That very well might be the answer Nikos needs. Nikos, is your SignalCommandMap swc/source up-to-date?
6 Posted by Nikos on 22 Nov, 2010 03:47 PM
thanks but all is up to date and still the problem. :(
7 Posted by Nikos on 22 Nov, 2010 05:59 PM
btw im using the SignalCommandMap source, where is the swc?
it seems the injection is been attempted before this line of code is being called
signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);
8 Posted by Nikos on 23 Nov, 2010 10:31 AM
perhaps the problem is that this mediator is mediating the contextView?
9 Posted by Nikos on 23 Nov, 2010 11:31 AM
Fixed it by reversing these:
//view
Stray closed this discussion on 11 Feb, 2011 10:27 PM.