Difference in mapping mediators from RL 1.0.3 to 1.1.2

Alastair's Avatar

Alastair

20 Aug, 2010 09:57 PM

Hey, I have the following in my context

override public function startup():void
{

// model 
this.injector.mapSingleton( BookProxy );

// view
this.mediatorMap.mapView( Book, BookMediator );

// controller
this.commandMap.mapEvent( ContextEvent.STARTUP_COMPLETE,    StartupCommand,         ContextEvent );

// add book to context
contextView.addChild( new Book() );

// go!
super.startup();

}

When using 1.1.2 I get an error ("Injector is missing a rule to handle injection into target") when injecting the mediator into a command, but when using 1.0.3 it works.

thanks!
Alastair

  1. Support Staff 1 Posted by Shaun Smith on 21 Aug, 2010 04:25 PM

    Shaun Smith's Avatar

    Is the failing injection target Book?

    RL 1.1.2 no longer injects into the view component of a view-mediator pair (this was a bug and has been fixed).

    When using the mediator pattern it is not recommended that you inject directly into your view components, but rather: inject into your mediator and pass the values through.

    If you really do want to inject into your view components then you must now explicitly do so from your mediator:

    // First, inject the Injector into the Mediator
    [Inject] public var injector:IInjector;
    
    // Then, inside onRegister (assuming your view component is called "view"):
    injector.injectInto(view);
    

    Hope that helps!

  2. 2 Posted by Abel de Beer on 21 Aug, 2010 07:24 PM

    Abel de Beer's Avatar

    @Alastair You're saying you want to inject your Mediator into a Command. The main reason this is difficult is because the only way your Mediators should communicate with the rest of the framework is through events (or signals). So instead of trying to inject the Mediator into a Command, have the Command (or other framework actor) dispatch an event that the Mediator is listenening for.

    Read more on this issue here: http://knowledge.robotlegs.org/faqs/framework-core/why-cant-i-injec...

  3. Support Staff 3 Posted by Shaun Smith on 21 Aug, 2010 07:33 PM

    Shaun Smith's Avatar

    Ah, sorry, I missed this: "when injecting the mediator into a command".. Thanks for picking up on that @abeldebeer

    The workaround, in that case, would be something like this:

    // First, inject the Injector into the Mediator
    [Inject] public var injector:IInjector;
    
    // Then, inside onRegister
    injector.mapValue(MyMediator, this);
    
  4. Stray closed this discussion on 16 Feb, 2011 09:05 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