Title: reusable components Post by: mono2k on February 12, 2008, 07:23:42 Hello!
Can someone guide me on developing reusable view components with puremvc/flex? My app has two views - welcome screen and failed login screen (WelcomeVew, FailedLoginView), both have the same SignupBoxView MXML component. SignupBoxView has a corresponding SignupBoxMediator. I'm using ViewStack to manage views: <mx:Application> I'm trying to register mediators in ApplicationMediator's constructor public function ApplicationMediator(viewComponent:Object) unfortunately, this not works for me, since app.failedLoginView is not a selectedChild of my ViewStack at the time of a facade startup and thus app.failedLoginView.signupBox is null. Am I doing something completely wrong? Title: Re: reusable components Post by: puremvc on February 12, 2008, 09:02:05 This is a deferred instantiation issue. Here's a post where I've explained how to handle this: http://forums.puremvc.org/index.php?topic=70.msg247#msg247
Believe me, all this will be turned into a FAQ soon, I promise :) -=Cliff> Title: Re: reusable components Post by: mono2k on February 12, 2008, 09:44:37 Hi Cliff! Thanks for an answer!
however, from adobe's documentation: Navigator containers such as Accordion, TabNavigator, and ViewStack implement the ContainerCreationPolicy.AUTO policy by creating all their children immediately, but wait to create the deeper descendants of a child until it becomes the selected child of the navigator container i.e. there is no point in listening a child's creationComplete event, rather we need to listen a child's child, this may be a code bloat... Could ViewStack's "change" event help? Title: Re: reusable components Post by: puremvc on February 12, 2008, 10:31:30 It all depends on the granularity of your view component / mediator.
And it doesn't matter what the depth of your child nesting is, the event will bubble. You just need to look at the UI component that was created and see what mediator register for it. -=Cliff> |