map different instances of the same view class to different mediator class

peterc's Avatar


18 Jun, 2010 05:29 PM

Hi, I am new to Robotlegs. I was wonder if it is possible to map different instances of the same view class to different mediator class. Maybe distinguishing the view by name, id or meta data?

  1. 1 Posted by Stray on 18 Jun, 2010 05:47 PM

    Stray's Avatar

    Hi Peter,

    It's one-view-to-one-mediator.

    But you can easily use strongly typed classes that just extend your view class, or contain it, to achieve the same goal.

    I've done that in my current app and it does also make the code clearer / easier to follow in my opinion.

    Hope that helps,


  2. 2 Posted by Maciek on 18 Jun, 2010 06:16 PM

    Maciek's Avatar

    The other alternative, if you can potentially have any number of different instances of the given view (e.g., you have a TabNavigator full of different application-created instances of your View), is to look at modular contexts in Modular RL (even if your app does not actually use Flex modules).

  3. 3 Posted by peterc on 18 Jun, 2010 10:20 PM

    peterc's Avatar

    Thank for the feedback guys. I guess a one to one mapping between view class and mediator class would make code easier to follow. I am just not too comfortable with creating empty subclass for the sole purpose of view to mediator mapping. But overall I find Robotlegs framework to be very enjoyable to work with. And one to one mapping is certainly something that I can live with.

  4. 4 Posted by Stray on 19 Jun, 2010 10:27 AM

    Stray's Avatar

    If you think of it in terms of objects rather than code, it's fine to have your two views wrapped in specific types - as well as creating the right mediator mappings, they clearly behave pretty differently (if they need diff mediators!) so in my mind that absolutely fits that they're different types of the same superclass.

    By subclassing them you declare that very clearly. I think it's a win, not a lose.

  5. 5 Posted by peterc on 21 Jun, 2010 10:20 PM

    peterc's Avatar

    Thanks Stray, that make sense. It might just be my personal coding style that is getting in the way.

  6. peterc closed this discussion on 21 Jun, 2010 10:22 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