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.
-D