Issue with signalCommandMap

Nikos 's Avatar

Nikos

15 Nov, 2010 04:44 PM

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;
    }


}

}

  1. 1 Posted by Stray on 15 Nov, 2010 05:32 PM

    Stray's Avatar

    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. 2 Posted by ZackPierce on 15 Nov, 2010 05:55 PM

    ZackPierce's Avatar

    basically, if the signal hasn't fired it won't yet exist as a singleton to be injected.

    I don't think this is the case. The contents of SignalCommandMap#mapSignalClass are:

    var signal:ISignal = getSignalClassInstance( signalClass );
    mapSignal( signal, commandClass, oneShot );
    return signal;

    getSignalClassInstance typically leads to createSignalClassInstance, 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 calling injector.getInstance(IInjector); , where the first injector there is the SignalCommandMap's internal IInjector, which is added at SignalCommandMap instantiation.

  3. 3 Posted by Nikos on 15 Nov, 2010 06:00 PM

    Nikos 's Avatar

    thanks guys, my context is doing this

    All my other signals get injected fine into my mediators

    package
    {

    import controller.AddCommentCommand;
    import controller.AddReviewCommand;
    import controller.AuthenticateLoginCommand;
    import controller.GetApplicationDataCommand;
    import controller.GetSelectedApplicationUserDataCommand;
    
    import model.CommentsModel;
    import model.ReviewModel;
    import model.UserModel;
    
    import org.robotlegs.base.ContextEvent;
    import org.robotlegs.mvcs.Context;
    import org.robotlegs.mvcs.SignalContext;
    
    import services.AuthenticationService;
    import services.CommentsService;
    import services.IAuthenticationService;
    import services.ReviewService;
    import services.UsersService;
    
    import signalz.GetAppDataSignal;
    
    import views.AddComments;
    import views.AddCommentsMediator;
    import views.ApplicationMediator;
    import views.LoginForm;
    import views.LoginFormMediator;
    import views.RatingView;
    import views.RatingViewMediator;
    import views.events.LDAP_LoginEvent;
    import views.signalz.AddCommentSignal;
    import views.signalz.AddReview;
    import views.signalz.ApplicationUserChanged;
    
    public class PR_SUITE_Context extends SignalContext
    {
        override public function startup():void
        {
    
    
    
            //model
            injector.mapSingleton(CommentsModel); 
            injector.mapSingleton(UserModel); 
            injector.mapSingleton(ReviewModel); 
    
    
            //service
            injector.mapSingletonOf(IAuthenticationService, AuthenticationService);
            injector.mapSingleton(CommentsService);
            injector.mapSingleton(UsersService);
            injector.mapSingleton(ReviewService);
    
    
            //view
            mediatorMap.mapView(LoginForm, LoginFormMediator);
            mediatorMap.mapView(AddComments, AddCommentsMediator);
            mediatorMap.mapView(PR_SUITE, ApplicationMediator);
            mediatorMap.mapView(RatingView, RatingViewMediator);
    
            //Command
            commandMap.mapEvent(LDAP_LoginEvent.LOGIN,AuthenticateLoginCommand);  
            signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
            signalCommandMap.mapSignalClass(AddReview,AddReviewCommand);
            signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);
    
    
    
    
            signalCommandMap.mapSignalClass(GetAppDataSignal,GetApplicationDataCommand);
    
            dispatchEvent(new ContextEvent(ContextEvent.STARTUP));
        }
    }

    }

  4. 4 Posted by Stray on 15 Nov, 2010 06:11 PM

    Stray's Avatar

    Hi Zack,

    I'm sure you're right - my fork of SignalCommandMap that I use is old and pre childInjector stuff.

    Thanks,

    Stray

  5. 5 Posted by ZackPierce on 15 Nov, 2010 06:20 PM

    ZackPierce's Avatar

    my fork of SignalCommandMap that I use is old and pre childInjector stuff.

    That very well might be the answer Nikos needs. Nikos, is your SignalCommandMap swc/source up-to-date?

  6. 6 Posted by Nikos on 22 Nov, 2010 03:47 PM

    Nikos 's Avatar

    thanks but all is up to date and still the problem. :(

  7. 7 Posted by Nikos on 22 Nov, 2010 05:59 PM

    Nikos 's Avatar

    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. 8 Posted by Nikos on 23 Nov, 2010 10:31 AM

    Nikos 's Avatar

    perhaps the problem is that this mediator is mediating the contextView?

  9. 9 Posted by Nikos on 23 Nov, 2010 11:31 AM

    Nikos 's Avatar

    Fixed it by reversing these:

    //view

        mediatorMap.mapView(LoginForm, LoginFormMediator);
        mediatorMap.mapView(AddComments, AddCommentsMediator);
        mediatorMap.mapView(PR_SUITE, ApplicationMediator);
        mediatorMap.mapView(RatingView, RatingViewMediator);
    
        //Command
        commandMap.mapEvent(LDAP_LoginEvent.LOGIN,AuthenticateLoginCommand);  
        signalCommandMap.mapSignalClass(AddCommentSignal,AddCommentCommand);
        signalCommandMap.mapSignalClass(AddReview,AddReviewCommand);
        signalCommandMap.mapSignalClass(ApplicationUserChanged,GetSelectedApplicationUserDataCommand);
    
  10. Stray closed this discussion on 11 Feb, 2011 10:27 PM.

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