PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: arisco97 on December 15, 2008, 09:47:46



Title: Handling flex mx:state addChild in puremvc (deferred creation)
Post by: arisco97 on December 15, 2008, 09:47:46
As I am using deferred instantiation, I do not see any way around having the mediator listen to state change events and determining when the addchild component is created. 

I have read about the puremvc statemachine, however I am wondering if anyone has a better approach of handling addchild views in puremvc.


Title: Re: Handling flex mx:state addChild in puremvc (deferred creation)
Post by: puremvc on December 16, 2008, 07:09:03
The StateMachine utility is really for implementing application-wide state management.

For handling added children, I suggest starting out looking at the Slacker demo.

The chief difference between that demo and what you are after is that the deferred instantiation is in the form of viewstack children that are created late, but never removed.

You would want a similar setup where a mediator will listen to either the app or custom component that will have children added to it when its state changes. Rater than listen for creationComplete events from the children, you'll listen for childAdded event (I believe; I'm using a limited wap browser so I can't doublecheck the API). Hook the added child to a new instance of the correct mediator. Have that mediator place a 'removed' eventlistener on the child. Whenever the child is removed from the view, its mediator should null its viewComponent property and unregister itself. 

-=Cliff>