PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: fidiman on October 01, 2008, 02:11:18



Title: A view componet can register herself to the facade ?
Post by: fidiman on October 01, 2008, 02:11:18
Hello,

A little question . In my app, i have many component, each one has his mxml file.

So i have the MainView > ViewStack > TabNavigator > ComponentHomeMade

Today,  for register my ComponentHomeMade to the facade i do this inside the component itself :

:
private function registerComponent():void
{
ApplicationFacade.getInstance().registerMediator( new ProduitVOListMediator( this ) );
}

and this is invoked on the addedToStage Event.

It's very usefull to do that (i can unregister it with removeFromStage).

But i'm thinking that it's not very clean, it seems that a view component would not have this responsabilty ?

Am I true or Not ?

Thanks again...


Title: Re: A view componet can register herself to the facade ?
Post by: puremvc on October 02, 2008, 06:18:07
In order to write more portable view components, don't give them any knowledge of the PureMVC app. They shouldn't know the Mediator or the Facade.

Have a read of the Best Practices doc and some of the AS3 Flex demos to understand how and when to register view components.

For instance, the Slacker demo shows how to handle late registration of deferred instantiation components. The EmployeeAdmin demo shows registration of components from a Command when they're all in place to begin with.

-=Cliff>


Title: Re: A view componet can register herself to the facade ?
Post by: fidiman on October 02, 2008, 11:52:40
thanks