Extending Mediators

Jono's Avatar

Jono

16 Sep, 2010 12:33 PM

Hi,

Question on if or how this works, or if I'm taking the wrong approach.

I have ViewA that extends Sprite - ViewB and ViewC both extend ViewA - All OK.

ViewB has MediatorB and ViewC has MediatorC.

MediatorB and MediatorC share almost the same code.

My question - Can I have a MediatorA that MediatorB and MediatorC extend?

Thanks,
Jono

  1. Support Staff 1 Posted by Shaun Smith on 16 Sep, 2010 03:34 PM

    Shaun Smith's Avatar

    Hello Jono,

    The short answer is: yes!

    In the current version of Robotlegs you need to use the third parameter (injectViewAs) of mediatorMap.mapView(). For example:

    mediatorMap.mapView(ViewB, MediatorB, ViewA);
    mediatorMap.mapView(ViewC, MediatorC, ViewA);
    

    In MediatorA you'd create a view dependency that looks like this:

    [Inject]
    public var viewA:ViewA;
    

    In MediatorB you'd cast that to ViewB:

    public function get viewB():ViewB
    {
        return viewA as ViewB;
    }
    

    And likewise with MediatorC.

    It's a bit of a pain, but will be made easier in a future version.

    Hope that helps!

  2. 2 Posted by Jono on 17 Sep, 2010 12:01 AM

    Jono's Avatar

    Hi Shaun,

    Help it did!

    Worked a treat, gotta say the fast responses on this forum make it a pleasure to know there is great support for RL.

    Thanks,
    Jono

  3. Jono closed this discussion on 17 Sep, 2010 12:01 AM.

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