PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: DEfusion on March 12, 2008, 04:43:02



Title: Mediators that may be registered before the view
Post by: DEfusion 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)?



Title: Re: Mediators that may be registered before the view
Post by: puremvc on March 14, 2008, 04:19:59
One thing here: Deferred instantiation is great, but OPTIONAL.

If the children of this viewstack are pretty simple, as I imagine from your description they are, then instead of jumping through hoops trying to deal with it in the framework, simply set creationPolicy=all in your viewstack and be done with it.

Remember this is a simple case. Deferred instantiation is the default behavior because it is expected that you want the most optimal startup experience. And if you have a stack with a ton of stuff in it that will take a long time to instantiate and so the perceived load time is longer.

Hope this helps,
-=Cliff>


Title: Re: Mediators that may be registered before the view
Post by: DEfusion on March 14, 2008, 05:04:14
Cheers Cliff, very helpful.


Title: Re: Mediators that may be registered before the view
Post by: puremvc on August 16, 2008, 04:12:50
Here's a link to the new FAQ entry for this issue:

http://puremvc.org/content/view/91/185/

-=Cliff>