Inherited mediators mapping

mikhail.kuts's Avatar

mikhail.kuts

28 Jul, 2014 06:06 PM

Hi all.
I have 2 pairs view/medaitor:

BView extends AView
BMediator extends AMediator

config:

mediatorMap.map(AView).toMediator(AMediator);
mediatorMap.map(BView).toMediator(BMediator);

As soon I added new instance of BView on stage - BMediator and AMediator are created.
How I can prevent AMediator creation?

Seems like I should use TypeMatcher, could anyone can help me find right way please? :)

  1. Support Staff 1 Posted by Ondina D.F. on 30 Jul, 2014 08:14 AM

    Ondina D.F.'s Avatar

    Hi Mikhail,

    Regarding TypeMatcher:

    As long as you don't map BaseView to BaseMediator, you can use TypeMatcher like this:

    mediatorMap.mapMatcher(  
        new TypeMatcher().allOf(BaseView,  View_A))
        .toMediator(Mediator_A);
    mediatorMap.mapMatcher(  
        new TypeMatcher().allOf(BaseView,  View_B))
    .toMediator(Mediator_B);
    

    where View_A and View_B extend BaseView, and Mediator_A and Mediator_B extend BaseMediator. BaseView and View_A will be injected into Mediator_A and BaseView and View_B will be injected into Mediator_B.

    Ondina

  2. Support Staff 2 Posted by Ondina D.F. on 30 Jul, 2014 08:37 AM

    Ondina D.F.'s Avatar

    See if this work for the BaseView/BaseMediator (I can't try it out right now):

    mediatorMap.mapMatcher(  
        new TypeMatcher().allOf(BaseView).noneOf(View_A, View_B))
        .toMediator(BaseMediator);
    
    mediatorMap.mapMatcher(  
        new TypeMatcher().allOf(BaseView,  View_A))
        .toMediator(Mediator_A);
    
    mediatorMap.mapMatcher(  
        new TypeMatcher().allOf(BaseView,  View_B))
    .toMediator(Mediator_B);
    

    Let me know how it goes.

  3. 3 Posted by mikhail.kuts on 01 Aug, 2014 01:14 PM

    mikhail.kuts's Avatar

    Thanks for your answer! Will try this way :)

  4. Support Staff 4 Posted by Ondina D.F. on 02 Aug, 2014 11:17 AM

    Ondina D.F.'s Avatar

    You're welcome!

  5. Ondina D.F. closed this discussion on 02 Aug, 2014 11:17 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