PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: Bigmama on March 20, 2008, 03:03:39



Title: Starting from Scratch.
Post by: Bigmama on March 20, 2008, 03:03:39
Hi, I don't know if any of you guys had a similar situation but here it goes.
I currently have a main panel which is the main screen on my app, and im willing to switch state onFileLoad.
Now, I have defined my custom MainPanel.mxml extending from panel and when the click Event is hit, I sendNotification(ApplicationFacade.CARGAR_PCU,SinManager);

Where should I place my state code, can I create a ErrorListState.mxml(would be my 2nd state for mainPanel), and how can i make the transition when i send the notification ?

Another Issue regarding good coding practices, is about nested CommandCalls.
I think it is not Ok to invoke a command within a command, but I have done it once in my app.
Should the good practice be, send a notification from commandA so controller can decide which command to execute, and reduce coupling between my commands ?
Thanks
Tom


Title: Re: Starting from Scratch.
Post by: trilec on April 01, 2008, 04:54:15
Hi Bigmama
in regards to a nested command calls:
you may want to check out the MacroCommand which is registered in the  ApplicationFacade . initializeController
 
In ApplicationFacade
:
override function initializeController() : void
        {
            super();
            registerCommand(APP_STARTUP, ApplicationStartupCommand);
}

example macro command
 
:
   public class ApplicationStartupCommand extends MacroCommand
    {

        public function ApplicationStartupCommand()
        {
            return;
        }
        override function initializeMacroCommand() : void
        {
            addSubCommand(ModelCommand);
            addSubCommand(ViewCommand);
            return;
        }

hope that helps some
Curt (Trilec)


Title: Re: Starting from Scratch.
Post by: puremvc on April 02, 2008, 07:30:46
You're not really coupling the Commands if you send a Notification from CommandA that triggers CommandB. You would be if you just instantiated CommandB inside CommandA, and that would be bad.

As for state, you can use Flex's states to create a single component that has multiple states and use the Mediator for that View Component to trigger the changes of state when it hears a particular Notification.

-=Cliff>