Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Let Mediator know it's been registered  (Read 5549 times)
nilsm
Jr. Member
**
Posts: 19


View Profile Email
« 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.
Logged
Rhysyngsun
Courseware Beta
Sr. Member
***
Posts: 51

Nathan Levesque

 - rhysyngsun@gmail.com  - rhysyngsun
View Profile WWW Email
« Reply #1 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.
Logged

puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 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>
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 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>
Logged
Pages: [1]
Print