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: [ FIXED ] Subcommand bug?  (Read 10834 times)
coursevector
Courseware Beta
Newbie
***
Posts: 4


View Profile Email
« on: March 11, 2008, 12:11:37 »

I'm trying to use a subcommand and facade isn't initialized. I believe the error resides in the MacroCommand class. At around line 116, add this line:

commandInstance.initializeNotifier( multitonKey );

and it seems to work as normal.
« Last Edit: March 11, 2008, 07:05:46 by puremvc » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 11, 2008, 01:19:18 »

Lots of eyeballs turn up the bugs quick! :)

I got this by email earlier from Milos:

Hello Cliff,

   I implemented multicore puremvc in my app and found one small bug.
   MacroCommands are not working corectly. The problem is in the execute method because subcommands are not initialized with the multitoneKey.

Solution is just to add

                commandInstance.initializeNotifier(multitonKey);

So the execute method should look like:

public final function execute( notification:INotification ) : void
        {
            while ( subCommands.length > 0) {
                var commandClassRef : Class = subCommands.shift();
                var commandInstance : ICommand = new commandClassRef();
                commandInstance.initializeNotifier(multitonKey);
                commandInstance.execute( notification );
            }
        }

Also one more note with the multicore framework if it is required to register something or to get facade instance for any reason in Mediator code it has to be done in the 'onRegisted()' method.

Keep up the good work!

--
Cheers,
Miloš
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: March 11, 2008, 05:12:08 »

Actually, Milos, the facade access can happen in initializeNotifier, before onRegister. You could wait until onRegister, but the following is what I did in the Modularity demo:

Inside SuperWidgetMediator:
:
override public function initializeNotifier(key:String):void
{
     super.initializeNotifier(key);
     superWidgetProxy = facade.retrieveProxy( SuperWidgetProxy.NAME ) as SuperWidgetProxy;
}

-=Cliff>
« Last Edit: March 11, 2008, 05:36:21 by puremvc » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: March 11, 2008, 07:06:32 »

This is corrected. The latest version of MultiCore is 1.0.1

Thanks, Milos!

-=Cliff>
Logged
zilet
Courseware Beta
Jr. Member
***
Posts: 17


View Profile WWW Email
« Reply #4 on: March 12, 2008, 01:21:46 »

Actually, Milos, the facade access can happen in initializeNotifier, before onRegister. You could wait until onRegister, but the following is what I did in the Modularity demo:


Yes that is ok, but somehow I like it more to put everything in the onRegister method.. It is logical place for me.

Thanks Cliff!
Logged
Pages: [1]
Print