PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: nilsm on February 08, 2008, 03:30:02



Title: Let Mediator know it's been registered
Post by: nilsm on February 08, 2008, 03:30:02
Hi everybody!

I've been knee-deep in PureMVC for a while now and it's occurred to me that it would be very useful for Mediators (and perhaps other elements) to be notified when they become registered with the Facade.

I'm working with Mediator instances that get registered and removed from the Facade at various points - but at the moment they have no knowledge of what's happening to them.

It's essential that they update their child-component's content again once they're re-registered, since they will have missed out on various notifications in the meantime.

[my use-case is a ViewStack, where it's not efficient to update views that are not visible]

Just wanted to open this up for discussion...

cheers - Nils.


Title: Re: Let Mediator know it's been registered
Post by: Rhysyngsun on February 08, 2008, 07:37:15
You could always have a MEDIATOR_REGISTERED notification that you send each time after you call registerMediator. You could then pass the name of the mediator in the body so that when mediators get the notification, they can only respond to ones with their name in the body. Unfortunately, since if you remove them, they no longer receiver notifications, this solution will not work for notifying the Mediator that it has been removed.


Title: Re: Let Mediator know it's been registered
Post by: puremvc on February 09, 2008, 08:54:46
Nils,

The framework design didn't anticipate a lot of register/unregister activity, though unregistration was provided for.

In the real world people are finding plenty of situations, paticularly with modules, where it is a necessary and natural thing to dynamically register and unregister Mediators, Commands and Proxies.

That the Mediator might need to know when it os registered or unregistered makes sense.

I will put it on the list for 2.0.

-=Cliff>


Title: Re: Let Mediator know it's been registered
Post by: puremvc on February 12, 2008, 10:28:55
In 2.0, the IMediator interface and Mediator class have onRegister and onRemove methods. They are called by the View after registration or removal is completed. All unit tests pass, including the new one to test this functionality.

-=Cliff>