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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Mediators give me headaches on: April 10, 2008, 02:36:50
I must be doing something wrong as I have no end of hassle with mediators trying to interact with their related view before the view is ready for the given interaction.

For instance the problem I have today is this:

> The user enters the application at a project page
> The app navigates to that section and goes off and loads the project
> The project gets loaded
> The following code in the mediator gets fired:

case ApplicationFacade.PROJECT_LOADED :
            var project:ProjectVO = note.getBody() as ProjectVO;
            // populate the project to the view if it's the project we're expecting
            if( project.id == projectOverview.projectId ) {
               projectOverview.project = project;
               projectOverview.selectedChild = projectOverview.details;

The problem is the first time the user does this I get an error when trying to set the selectedChild of the viewstack, as I'm guessing the component isn't complete yet. However I must have only just introduced this issue as it was working fine a couple of days ago, but the thing is I've not actually touched this mediator or it's view, just added something else that handles the PROJECT_LOADED notification.

I've read the best practices and everything else I can get my hands on (look through the examples etc.) but I'm still having issues with mediators.

For example in my dashboard mediator (the dashboard is usually the first thing the user sees after login) I have this kludge in the constructor:

this.dashboard.addEventListener( FlexEvent.SHOW, showDashboardHandler );
if( this.dashboard.visible ) this.showDashboardHandler();

As I say sometimes the user isn't always taken straight to the dashboard after the login (thus the event listener handles whenever they navigate to that section and it's displayed) whereas when they are taken straight there after login it's already visible by the time the constructor runs (which is fine).

Any thoughts are greatly appreciated.

2  Announcements and General Discussion / Architecture / Mediators that may be registered before the view on: March 12, 2008, 04:43:02
Currently I have the following setup:

ModelPrepCommand & ViewPrepCommand register the core proxies and mediators required for the app to startup (basically the login screen and the login proxying). However part of the login checking is to check to see if the user is logged in from a previous session (using a "remember me" feature) so sometimes the login screen (a child in the main viewstack) is never displayed at all. This means that when I log in in this manner and then logout the login mediator throws an error when it's trying to set a 'you have logged out message' on the login view - as the view component hasn't been initialised by Flex yet.

I've read this post on deferred instantiation and tried that, by only adding the mediator (if it isn't already registered) when the viewstack displays the login screen. That stops the error, but obviously by the time the mediator is added the LOGGED_OUT notification has been and gone (or not, but either way the mediator wasn't registered before the LOGGED_OUT notification was sent), is this an edge case scenario or do I need to look at how I'm handling my 'logged out' message to the user (such as move the message to the proxy)?

3  Announcements and General Discussion / General Discussion / Testing practices for Pure MVC on: February 28, 2008, 06:02:01
I just wondered if anyone had any best practices for unit testing/functional testing your Pure MVC application (mine is in Flex).

I was thinking you could test the views & your models/business objects pretty easily, but it would be nice to test that all the command/proxies/mediators etc. are setup and working as expected.

Any thoughts?
Pages: [1]