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: A view componet can register herself to the facade ?  (Read 8421 times)
fidiman
Full Member
***
Posts: 23


View Profile Email
« 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...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
fidiman
Full Member
***
Posts: 23


View Profile Email
« Reply #2 on: October 02, 2008, 11:52:40 »

thanks
Logged
Pages: [1]
Print