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: Mediators that may be registered before the view  (Read 9796 times)
DEfusion
Courseware Beta
Jr. Member
***
Posts: 16


View Profile Email
« 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)?

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



View Profile WWW Email
« Reply #1 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>
Logged
DEfusion
Courseware Beta
Jr. Member
***
Posts: 16


View Profile Email
« Reply #2 on: March 14, 2008, 05:04:14 »

Cheers Cliff, very helpful.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 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>
Logged
Pages: [1]
Print