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: Mediator registration for viewstack views  (Read 7582 times)
sasuke
Full Member
***
Posts: 29


View Profile Email
« on: May 01, 2010, 01:32:40 »

Hi,

My module which has a facade of its own (ModuleFacade) looks something like this:

:
<mx:Module>
  <mx:ViewStack creationPolicy="auto">
    <mx:View1 />
    <mx:View2 />
  </mx:ViewStack>
</mx:Module>

The page loads, the facade is kicked in action, the module mediator is registered, the module mediator receives the confirmation, another command is fired to register the View1, the mediator for view1 is registered and the control reaches the view1 mediator from the registration command. All this works fine. The problem comes when the user switches view. Since the creation policy of my view stack is auto (can't create all views at once), the view2 mediator registration happens before the view2 has been completely created and this results in an error when I try to access my view2 components after the startup command for the view2 completes.

I can attach a creationComplete event listener to the view2 and make the listener function look up the facade, send the notification to the module mediator which in turn would pick up view2 and send it for registration. But this doesn't seem like a very good approach, I mean referring/lookingup facade in each and every view instead of just the main view. Is there any other approach I can use to tackle this problem or is this the only choice?

TIA,
sasuke
« Last Edit: May 01, 2010, 12:13:57 by sasuke » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 03, 2010, 01:18:41 »

Have a look at the FAQ entry for deferred instantiation. http://puremvc.org/content/view/91/188/

The Slacker demo shows one way of handling this: http://trac.puremvc.org/Demo_AS3_Flex_Slacker

-=Cliff>
Logged
sasuke
Full Member
***
Posts: 29


View Profile Email
« Reply #2 on: May 04, 2010, 10:50:26 »

The demo looks interesting, thanks. :)
Logged
Pages: [1]
Print