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: Load View & Mediator based on Remote Proxy result  (Read 10090 times)
tobydeh
Port to Python
Sr. Member
*
Posts: 52


View Profile Email
« on: January 23, 2008, 06:57:25 »

Hi,

I am having trouble making a design decision...

When a user clicks on a category from the menu the following needs to occur:

1) The MenuMediator sends a notification which is bound to a LoadCategoryCommand

2) The LoadCategoryCommand needs to check which view and mediator to load

2 a) LoadCategoryCommand asks the CategoryProxy if the selected category owns any child categories. If so load the category view. If not -> 2b
2 b) LoadCategoryCommand asks the ProductsProxy if the selected category
owns any products. If so load the product view. if not -> 2c
2 c) LoadCategoryCommand asks the PageProxy is the selected category owns a page. If so load the page view. If not redirect the user / display error.

My problem is that the LoadCategoryCommand cannot listen for updates from the proxies, and the proxies must dispatch an event because they are loading XML from a remote URL...

Where should I handle the updates from the Proxies, and then decide which view to load.

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



View Profile WWW Email
« Reply #1 on: January 23, 2008, 09:40:10 »

Due to the asynchronous nature of service interaction, you have to break this decision making process into several steps. You cannot do it all in one command.

-=Cliff>
Logged
tobydeh
Port to Python
Sr. Member
*
Posts: 52


View Profile Email
« Reply #2 on: January 23, 2008, 09:45:32 »

Could you explain further?

The calls are split across proxies...
Logged
nilsm
Jr. Member
**
Posts: 19


View Profile Email
« Reply #3 on: January 25, 2008, 05:27:56 »

Hi Toby,

expanding on what Cliff wrote, here is a solution using a single Notification name and different types to differentiate between the stages of the operation:

- Notification fires, no type set - LoadCategoryCommand starts loading CategoryProxy XML and exits

- CategoryProxy XML finishes loading data - and fires the same Notification but with type set to 'categoryLoaded'

- LoadCategoryCommand executes again, sees the new 'type' identifier and a) displays the page or b) triggers the ProductProxy to load data - and then exits

- Finally, ProductProxy finishes loading data - and fires the same Notification but with type set to 'productLoaded'

- LoadCategoryCommand executes again, sees the new 'type' identifier and displays the appropriate page

Might seem complicated but you end up using a single Notification and a single command that encapsulates the entire logic for displaying the category.

Any good for you?

- Nils.
Logged
Pages: [1]
Print