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: Registering Multiple Instances of one Mediator and Proxy  (Read 6940 times)
Ilan Avigdor
Courseware Beta
Newbie
***
Posts: 5


View Profile WWW Email
« 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

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




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



View Profile WWW Email
« Reply #1 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>
Logged
Ilan Avigdor
Courseware Beta
Newbie
***
Posts: 5


View Profile WWW Email
« Reply #2 on: March 14, 2009, 09:38:20 »

I used the term "registration" but indeed meant to construction.

Thanks !
Logged
Pages: [1]
Print