Mapping the Main Application (contextView) Mediator - good idea or bad

lcfsoft's Avatar

lcfsoft

22 Feb, 2012 08:39 AM

Hello,

In the "Best Practices" document (https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices), they say it's a common pattern to do so (subj) and provide us with some specifics (e.g. we have to create the mediator for an application manually, by calling createMediator)

When checking the code (because of another issue) I discovered this comment in the MediatorMap.mapView:

// This was a bad idea - causes unexpected eager instantiation of object graph 
if (autoCreate && contextView && (viewClassName == getQualifiedClassName(contextView) ))
    createMediatorUsing(contextView, viewClassName, config);

so, seems like if we map the contextView - it creates mediator right away, automatically. and for some reason it is a bad idea.

Two questions here:
1. Is that statement about creating a mediator manually valid?
2. Is it bad idea or good? By design it seems to be good and even "only possible" idea as the Application itself is nothing but just a view.

Thanks.

This discussion was closed! See this FAQ for more information:

  1. Can I Mediate my Root Application?

    Yes:

    mediatorMap.mapView( MyAppView, MyAppViewMediator );
    

    The contextView is now fully mediated and can send and receive framework events.

    IMPORTANT: It is important to understand that this behavior can have unexpected consequences. Because the contextView is generally already on stage at the time of mapping, Robotlegs creates a mediator for the contextView immediately as soon as you map it - th...

    See more..
  1. lcfsoft closed this discussion on 22 Feb, 2012 08:41 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