Title: Load View & Mediator based on Remote Proxy result Post by: tobydeh 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. Title: Re: Load View & Mediator based on Remote Proxy result Post by: puremvc 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> Title: Re: Load View & Mediator based on Remote Proxy result Post by: tobydeh on January 23, 2008, 09:45:32 Could you explain further?
The calls are split across proxies... Title: Re: Load View & Mediator based on Remote Proxy result Post by: nilsm 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. |