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: listNotificationInterests  (Read 11034 times)
arisco97
Jr. Member
**
Posts: 14


View Profile Email
« on: June 26, 2008, 03:05:35 »

Pardon my limited expertise.

In implementing mediator on flex, I realize the listNotificationInterest method is executed during the construction of the mediator. Is there a method available to dynamically modify the notification list after mediator is constructed. I have a generic mediator which supports multiple views, so I want to include a notification in mediator under the event handler scope instead of the construction phase - as the notification value will only be available on creationComplete of the view.

Thank you.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: June 26, 2008, 07:43:19 »

So your mediator needs to return a different list of notification interests based upon what view component it has been created with.

Realize that construction of the mediator and registration of the mediator with the view are two separate processes.

You will create the mediator, passing in its already created view component in the mediator constructor.

So just have the listNotificationInterests method  return a different list based upon the view component.

When you register the mediator it will be the listNotifications method is called.

If you later remove that mediator from the view and change its viewComponent, when you reregister it it will receive the appropriate notifications for the new view component.

-=Cliff>
Logged
arisco97
Jr. Member
**
Posts: 14


View Profile Email
« Reply #2 on: June 26, 2008, 08:21:08 »

Cliff thanks. I understand your info, but I am missing one more thing. So really appreciate your insight.

My use case is simple. Verify a bunch of HTTP services. The request params are prompted using Form. Although the services are different from each other, they also share a common set of parameters. So I implemented a GenericView with a standard form containing the common set of form items and the submit process. Next I extended the GenericView to respective Service#1View, Service#2View etc. Each ServiceView uses addChildAdd to introduce additional form items and overrides the submit process.

Now the ServiceViews are under a ViewStack. So the mediator gets handed the ServiceView Object accordingly. However the mediator does not know which child view was passed, so I simply cast to GenericView to access view attributes in the mediator, and I really only need access to attributes defined in the GenericView.  Now since I don't know the view, I have to assign a generic notification id between the mediator and the model. However I can not support a multi threaded model effectively.

So if Service#1View was invoked,
- I want the mediator to first retrieve the generic model.
- Then mediator will tell generic proxy to notify back using notification "Service#1View".
- Then mediator will kick off model process.
- Model will notify using the "Service#1View" when it has fault or result event.
- Mediator will then update the response area which is inside GenericView.

Explain to me what happens when the same instance of Flex runs Service#1View and Service#2View concurrently. I have to use a unique notification to track them.

What I am saying is I need listNotificationsInterest to be kicked off after the View object is created. While debugging I found that listNotificationInterest is executed as part of the construction phase. Is there a possibility of calling listNotificationInterest out of the event handler coming from the view submit event?

Thanks.



Logged
arisco97
Jr. Member
**
Posts: 14


View Profile Email
« Reply #3 on: June 26, 2008, 08:26:38 »

Also Cliff forgot to mention that the mediator try to access unique notification by accessing a public variable implemented in GenericView, but populared by the ServiceView.

So how can I access a view property before executing listNotificationsInterests? I am assuming the view coupling is after mediator creation, and here it looks like listNotificationsInterests happens before view coupling.

THANKYOU.
Logged
arisco97
Jr. Member
**
Posts: 14


View Profile Email
« Reply #4 on: June 26, 2008, 09:02:57 »

I saw your MainDisplayMediator.as example, and now seem to get the idea. Please see my previous thread, as I would like you to suggest something more appropriate for the usecase.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: June 27, 2008, 04:56:55 »

2 things: 1) Flex is not multi-threaded, and 2) use the type property of the notification as a discriminator. Proxies can target a specific mediator for a notification that several mediators may be interested in by setting type to a   shared key of some sort. The mediator will compare the note type to their own key and only take action on a match.

Hope this helps.
-=Cliff>
Logged
Pages: [1]
Print