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: Managing multiple windows with pure MVC.  (Read 9304 times)
itnilesh
Newbie
*
Posts: 6


View Profile Email
« on: February 07, 2012, 07:01:41 »

In my application there are multiple screens which can be  minimized like in windows desktop. Now each has different instances of mediator which have same notification. So if I do changes in one screen say press some button >> which sends some command >> to proxy >>then proxy sends notifications to mediator.

But as multiple screens are active there it is showing changes in all screens as they are notified too by proxies .

How to make sure that proxy calls to particular view component (mediator ) and not for all live instances of mediators ?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: February 07, 2012, 08:58:55 »

Basically you want to use the type property of the Notification as a discriminator that says which Mediator the note is intended for. This has been discussed in several threads already, so I'll just point to some of them here in no particular order:

http://forums.puremvc.org/index.php?topic=843.msg3812#msg3812
http://forums.puremvc.org/index.php?topic=231.0
http://forums.puremvc.org/index.php?topic=1059.msg4853#msg4853
http://forums.puremvc.org/index.php?topic=596.msg2632#msg2632

Cheers,
-=Cliff>
Logged
itnilesh
Newbie
*
Posts: 6


View Profile Email
« Reply #2 on: February 07, 2012, 09:28:12 »

Thanks Cliff for reply .

But in my case situation is quite nasty .I browsed your replies in this forum for this .

My situation -
First I have multiple windows/views  in that window say A has child B and  B has child C (A--> B --> C --->  depth May increase in future :( ).Child of B , which is C  is created when action is called on it from B.

Say there are some buttons on C because of which B need refrsh .

Now From you forum I get message that A is parent of B ,C so if C need to refresh B then it should fire event which A will listen and refresh B through its mediator as it has handle to its child B . am I right here
If I have to do conversation between children B and C I have to go through parent A ??
Another question is how to register event for C in mediator of  A because C is created when it is needed means when someone clicks button on B .

Any elegant clean solution for this where I have multiple windows and depth of child more than 3 .?


« Last Edit: February 07, 2012, 09:45:49 by itnilesh » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: February 07, 2012, 09:52:46 »

If I have to do conversation between children B and C I have to go through parent A ??
No, you can always send an event from C that is listened for and acted on by B.

Mediation isn't really needed for communication between parent and child view components. Parents may set properties and call methods on their children, and children can send events to communicate changes to their parents. Mediators are important when other actors in the system need to be made aware of actions taking place at the view without having to know where the information came from, or need to send information to the view without caring where it is being consumed.

-=Cliff>
Logged
itnilesh
Newbie
*
Posts: 6


View Profile Email
« Reply #4 on: February 07, 2012, 10:02:03 »

If i have to do communication with A view from C (UPDATE A's properties from actions of C here B's state is not affected .) will it go through B or directly to A view ?

if directly to A then A should have handle of Object of C to register event on it  .And if C is created when needed ,  in that case C is not available to A when A is created :(
« Last Edit: February 07, 2012, 10:09:48 by itnilesh » Logged
itnilesh
Newbie
*
Posts: 6


View Profile Email
« Reply #5 on: February 08, 2012, 02:20:59 »

@puremvc

if my project has such up to 4 level children structure should I support multiple windows .

My each window as structure of A >> B >> C >> D .Due to this depth code is becoming complex to manage identifiers for mediators.


Because it is becoming very complex and code seems to be unmanageable .
Can you give advice on this ?

Even though I have made approach as you suggested


For each notification send identifier and returned that back using async token .For each action in D I have to bubble that up to C and if C refreshed I have to bubble up to B and so on ....
Such events are becoming so much that .....it is needing complete refracting of notifications and existing code in
command , proxy and mediator , view .

CAN YOU GIVE ADVICE THAT WILL IT BE BETTER TO KEEP THIS APPLICATION SINGLE WINDOW SUPPORTED ?
PLEASE HELP ME IN THIS CASE .
Logged
itnilesh
Newbie
*
Posts: 6


View Profile Email
« Reply #6 on: February 08, 2012, 07:53:18 »

@ PureMVC

I got another solution

As each window has children link A>>B>>C>>D say I use unique identifier for this branch so that I can use say parent ID as identifier for all elements in  A,B,C,D because of this if child want to update parent there is no need to send event .But just notification .This will not affect another window as all mediator who are checking identifier has diff identifier of that window :)
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #7 on: February 08, 2012, 03:09:30 »

If i have to do communication with A view from C (UPDATE A's properties from actions of C here B's state is not affected .) will it go through B or directly to A view ?

if directly to A then A should have handle of Object of C to register event on it  .And if C is created when needed ,  in that case C is not available to A when A is created
No, A does not need a reference to C to set an event listener on it, if C sends a bubbling event up the displaylist, then A can listen to B for the event that C dispatches.

My each window as structure of A >> B >> C >> D .Due to this depth code is becoming complex to manage identifiers for mediators.
You are presenting this very abstract terms. This makes it difficult for me to give advice, since I do not know the real relationship between any of these window/view components.


-=Cliff>
Logged
Pages: [1]
Print