from PureMVC to RobotLegs...bestPractices for startup

jbach's Avatar

jbach

22 Mar, 2010 11:37 PM

Ok
Need some help as I get up to speed with RL.

1
To start, am I correct in thinking of Context as Facade in PureMVC?

2
Is a Startup Command necessary?

3
How would I translate the following (from Application facade and StartUpCommands in PureMVC) in my ApplicationContext file?

//CODE START //StartupCommand start facade.registerProxy(new DataProxy(app));

        facade.registerMediator(new StageMediator(stage));
        facade.registerMediator(new ApplicationMediator(app));

//StartupCommand end //ApplicationFacade start

override protected function initializeController():void

    {
        super.initializeController();

        registerCommand(Constants.CMD_STARTUP, StartupCommand);
    }

    public function startup(stage:Object):void
    {

        sendNotification(Constants.CMD_STARTUP, stage);
    }

//ApplicationFacade end

  1. 1 Posted by Jonny Reeves on 23 Mar, 2010 11:00 AM

    Jonny Reeves's Avatar

    Hi There,

    Your formatting got a bit screwed up there, but I think what you're looking for is ContextEvent.STARTUP_COMPLETE, for example:

    package foo.bar
    {
        import foo.bar.command.BootstrapApplicationCommand;
        import org.robotlegs.base.ContextEvent;
        import org.robotlegs.mvcs.Context;
        import flash.display.DisplayObjectContainer;
    
        public class BarContext extends Context 
        {
            public function BarContext(contextView : DisplayObjectContainer = null, autoStartup : Boolean = true)
            {
                super(contextView, autoStartup);
            }
    
            override public function startup() : void 
            {
                // Executes BootstrapApplicationCommand as soon as this method completes.
                commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, BootstrapApplicationCommand, ContextEvent, true);
    
                // Causes the ContextEvent.STARTUP_COMPLETE to be fired.
                super.startup();
            }
        }
    }
    

    To answer your questions directly; most people are content with putting their Command Mappings, Mediator Mappings and Injector Mappings into their Context's startup() method. However, I personally prefer to have a Bootstrap Command which itself calls a chain of Commands to get things setup and ready to roll.

    Jonny.

  2. Shaun Smith closed this discussion on 20 Jun, 2010 04:24 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac