PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: Ilan Avigdor on March 14, 2009, 05:44:25



Title: Registering Multiple Instances of one Mediator and Proxy
Post by: Ilan Avigdor on March 14, 2009, 05:44:25
Hi,
I would like to suggest another approach for the same issue discussed in the original post:
http://forums.puremvc.org/index.php?topic=596.0 (http://forums.puremvc.org/index.php?topic=596.0)

The original discussion suggests the mediator using the type property of the notification as a discriminator, only taking action if it matches its own name.
This approach results in multiple mediators being called to handle the same notification, while only a single one is actually interested in it and taking an action.

I would suggest using the notification name for pairing mediators and proxies in the following way:
The same as in the original post, both mediator and proxy pair are given a unique key on registration.
The mediator adds this key to its list of notifications interests.
This key serves as the name parameter of the notification leaving the Proxy.
This way, these notifications are handled only by the mediator who included this name in its list of notifications interests - the corresponding pair.

Any thoughts are welcome.

Cheers,

-Ilan






Title: Re: Registering Multiple Instances of one Mediator and Proxy
Post by: puremvc on March 14, 2009, 07:44:50
The key couldn't be added at registration, as in onRegister, the mediator's listNotificationInterests method will have been called and won't be called again. So this key would need to be passed into the constructor of the mediator, where it would be added to a private or protected interests array, that would be returned later at registartion time by the listNotificationInterests method.

Otherwise this sounds like a workable solution.

-=Cliff>


Title: Re: Registering Multiple Instances of one Mediator and Proxy
Post by: Ilan Avigdor on March 14, 2009, 09:38:20
I used the term "registration" but indeed meant to construction.

Thanks !