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 complex UI states  (Read 6545 times)
rjewson
Newbie
*
Posts: 1


View Profile Email
« on: September 19, 2008, 06:07:59 »

I'd currently designing a Flex application that has several base window state (probably a viewstack) and several custom controls for nagivation that work on some or all the views.  Controls not required for a certain base window will be removed and added as required.

My question is this.  In most of the examples, management of the visual state of the application seems to be left to a base application or UIComponent mediator.  Is this the best way?  What about utilizing a Command to manage the state of the interface to transition Flex states and change the view stack?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: September 20, 2008, 05:38:19 »

You can use a Command if you feel so inclined but a Mediator is the mor natural place to handle interaction with the view component, since it is meant to be the sole touchpoint within the system tha knows about a given view component.

-=Cliff>
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #2 on: February 25, 2009, 12:18:26 »

Cliff, I've been really struggling with this lately and am wondering if you can expand on this point. I have logic that usually happens in a Mediator in regards to a component (saying moving a tab from a TabNavigator) and some other stuff like de-registering a proxy and or mediator. Since I want to have this in a command for reusability (I need this since it can be called from multiple places, keyboard shortcuts, buttons, etc.) how do you get around retrieving a mediator and accessing the viewComponent?

For example, I have a tab based interface for easy multi tasking. I can open a UserProfile tab and a second one for another user and edit or view both at the same time by switching between them. The problem I have is when closing it its not so simple as removing the tab from the TabNavigator (usually handled by an ApplicationMediator or mediator for that component, depending on complexity).

In a CloseUserProfileCommand, I would want to remove the userProfileVO from the UserProfileProxy collection, de-register the mediator (and any other child mediators), etc. etc. but I'd like to keep the removal of the child tab in that command as well, keeping everything in one place. Do you have a suggestion for this type of view logic and whether being in a command or not? Maybe some examples of situations you've run into and how you approached it?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: February 25, 2009, 09:11:06 »

a CloseUserProfileCommand, I would want to remove the userProfileVO from the UserProfileProxy collection, de-register the mediator (and any other child mediators), etc. etc. but I'd like to keep the removal of the child tab in that command as well, keeping everything in one place.

Multiple events (menu clicks, keypresses etc can send the same note, but it doesn't have to trigger a command.

I would have the mediator responsible for the tabnavigator be interested instead of registering a command. It is the sole touchpoint in the app for that component, so have it do the removal of the tabnav child. 

Then have that view component's mediator remove itself by listening to its REMOVED event.

I'd also have the mediator make a cal to the proxy to remove the item being closed. The mediator knows the item and can talk to the proxy.

So a button click, menu selection or a keypress led to the note that caused the  tabnavmediator to remove the child, which sent a REMOVED event to its mediator which told the proxy to remove the associated item from its collection, and then de-registered itself.

-=Cliff> 
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #4 on: February 26, 2009, 08:20:06 »

You always know how to save the day Cliff! Thanks again! The points you made really helped out and in this case makes sense to centralize it there.
Logged
Pages: [1]
Print