Mediator onRegister() vs. Dependency Injection of Signals

jason.merrill's Avatar


31 Aug, 2011 07:25 PM

I am injecting a signal into a view:

[Inject] public var playbookInteractionCompletedSignal:PlaybookInteractionCompletedSignal;

That signal is mapped to the injector, and the view's mediator is mapped to the view, all in the context::


mediatorMap.mapView(PlaybookView, PlaybookViewMediator);

The signal is injected into the view's mediator (PlaybookViewMediator), and the signal listened to in the onRegister method of the mediator. The view being listened to is also injected:

[Inject] public var playbookInteractionCompletedSignal:PlaybookInteractionCompletedSignal;

[Inject] public var playbookView:PlaybookView;

override public function onRegister():void {



The problem is that I am getting a runtime error in the PlaybookViewMediator - that line above in the onRegister method where I add the handler to the signal, and I can't figure out why.

Any help is greatly appreciated.

Jason Merrill

  1. Support Staff 1 Posted by Stray on 31 Aug, 2011 07:55 PM

    Stray's Avatar

    Hi Jason,

    Robotlegs doesn't inject into views unless you use the viewMap - and the viewMap and mediatorMap aren't really intended to be used together - it's generally a 'one or other' approach.

    Why are you injecting the signal into the view using [Inject]? Options include creating the signal as a property of the view, or passing it manually from the mediator into the view itself. Either way, the approach you have at the moment looks like too much reliance on the injector to me - there are much simpler ways to get the job done.

    Also, you'll need to use SignalMediator and SignalMap to avoid memory leaks when using signals in mediators - check them out on github.

    I don't think you're far from a solution - just don't rely on the injector to provide that signal to the view and you'll be golden.


  2. 2 Posted by jason.merrill on 01 Sep, 2011 01:45 AM

    jason.merrill's Avatar

    Thanks Stray. Everything I was doing I thought was the way I should be doing it, so I'll try your suggestions. Thanks so much!

  3. 3 Posted by jason.merrill on 01 Sep, 2011 06:16 PM

    jason.merrill's Avatar

    Ok - got it working. Yeah, I was over-injecting was the problem (I was already using SignalMediator - also SignalCommandMap - but what is SignalMap?).

    So it's working great now, thanks!

  4. 4 Posted by Stray on 01 Sep, 2011 06:22 PM

    Stray's Avatar

    Ah! cool :)

    SignalMap is used internally by SignalMediator - so as long as you use "addToSignal(... )" you're golden. Basically if you add your handlers directly then you need to clean up manually when the mediator is destroyed (when the view leaves the stage). If you use SignalMap (through SignalMediator) then you get automatic clean up.


  5. 5 Posted by jason.merrill on 01 Sep, 2011 07:01 PM

    jason.merrill's Avatar

    Oh cool - I am using addToSignal now in my SignalMediator and it works great - thanks! That's awesome.

  6. Ondina D.F. closed this discussion on 01 Nov, 2011 04:10 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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