Mediator control Clips within View??

brucealmighty 's Avatar

brucealmighty

15 Sep, 2010 04:33 PM

Hi

Just wondering what the best approach is for the Mediator to control the Clip within a the View... for example:

FamilyMediator - FamilyView

Within FamilyView there could be - granddadView, fatherView, childView...

So in a stiuation where the childView dispatches an Event, that FamilyMediator can pick up through (eventMap.mapListener(eventDispatcher) I assume, what would be the best approach to control the childView..

Would it be ok to directly access the childView from FamilyMediator for instance (FamilyView.childView.dosomething()), I'm thinking that would tightly couple the view and mediator.

Or could I dispatch an event from the FamilyMediator, that childView within the FamilyView could be listening to, this way I feel the FamilyView won't neccesary be tied to the FamilyMediator, assuming this is ok I would prefer to use AS3 signal, how would I go about it.

Thanks in advance

  1. 2 Posted by Stray on 15 Sep, 2010 04:49 PM

    Stray's Avatar

    I'm a big fan of AS3Signals for deeper view/mediator relationships.

    It's not ideal for the FamilyMediator to go digging around.

    Mediator granularity is very easy to vary - so you can have fatherViewMediator etc if there are more specifics that need tying up.

    Lx

  2. Support Staff 3 Posted by Shaun Smith on 15 Sep, 2010 05:02 PM

    Shaun Smith's Avatar

    More than one dot (familyView.childView.dosomething()) creates structural coupling, as you hinted at, and forces the mediator to know implementation details that it shouldn't care about.

    Instead, your view component should expose an api (interface) that the mediator would talk through (familyView.doSomthing()) - the view would manage the actual implementation details internally (funneling the call through to a child for example).

  3. 4 Posted by brucealmighty on 15 Sep, 2010 05:14 PM

    brucealmighty 's Avatar

    Thanks

    @Shaun, I may have been overthinking it, but I guess its ok for the familyView to know about the internal workings of childView, my original thought was, to exclude familyView from the communication, as it's not directly involve what the childView as too do.

    @Stray I have used AS3 signals, but I haven't really seen an example or know if its possible.. using the example in my original post.

    have ChildView dispatch signal that a Family Mediator can pick up, without having FamiliyMediator having direct access to the ChildView, if that makes sense.

  4. 5 Posted by Stray on 15 Sep, 2010 09:04 PM

    Stray's Avatar

    Is there a reason why you're not mediating the ChildView directly in this case?

    It sounds to me like that would be a better solution, because otherwise you're going to end up with a lot of unnecessary code / coupling just to avoid the double-dot.

  5. Stray closed this discussion on 12 Feb, 2011 11:02 PM.

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