PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: Lazerwonder on April 07, 2010, 02:24:09



Title: Mediators to Mediators
Post by: Lazerwonder on April 07, 2010, 02:24:09
Hi,

I'm just starting to use pureMVC and I have a couple of questions... (I don't want to break any pureMVC BP and rules):

1. I was wondering -- is it okay to use notifications to talk from mediators to mediators?  Or do I have to have mediator #1 to talk to a command, which dispatches another notification that mediator #2 will be interested in?

2. Parent mediators *can* have access to children mediators... question is, is this a BAD thing to do?  Like, if in a mediator, I'm registering another mediator... and then in that parent mediator, I want to access a function in that child mediator... is that breaking any BP or rules?


Thanks. :)


Title: Re: Mediators to Mediators
Post by: puremvc on April 08, 2010, 08:56:56
1. I was wondering -- is it okay to use notifications to talk from mediators to mediators?  Or do I have to have mediator #1 to talk to a command, which dispatches another notification that mediator #2 will be interested in?
Not a problem. Mediator to Mediator communications is a perfectly fine way of creating view hierarchy that doesn't need top-down command logic to achieve self-organization.

2. Parent mediators *can* have access to children mediators... question is, is this a BAD thing to do?  Like, if in a mediator, I'm registering another mediator... and then in that parent mediator, I want to access a function in that child mediator... is that breaking any BP or rules?
Though a Mediator may create and register another Mediator for a child of it's own view component, it shouldn't puppeteer that new Mediator anymore than it should its own view component. Don't keep the reference to the new Mediator. Send it a notification to it like any other decoupled entity in the system.

-=Cliff>