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: multitonKey for this Notifier not yet initialized!  (Read 19040 times)
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« on: April 10, 2008, 03:36:34 »

Trying to understand this error:

Error: multitonKey for this Notifier not yet initialized!
   at org.puremvc.as3.multicore.patterns.observer::Notifier/get facade()
   at app.guildgrid.view::StageMediator()
   at app.guildgrid.control.command::ApplicationStartUpCommand/execute()
   at org.puremvc.as3.multicore.core::Controller/executeCommand()
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at org.puremvc.as3.multicore.patterns.observer::Observer/notifyObserver()
   at org.puremvc.as3.multicore.core::View/notifyObservers()
   at org.puremvc.as3.multicore.patterns.facade::Facade/notifyObservers()
   at org.puremvc.as3.multicore.patterns.facade::Facade/sendNotification()
   at app.guildgrid::ApplicationFacade/startup()
   at Application/creationComplete()
   at Application()
ApplicationStartUpCommand
:
override public function execute(notification:INotification):void
{
  // Register the stage Proxy
  facade.registerProxy( new StageProxy() );
  // Register the main application Mediator, stage in this case
  facade.registerMediator( new StageMediator( Stage ) );
}
StageProxy
:
public class StageProxy extends Proxy implements IProxy
{

public static const NAME:String = "StageProxy";
/// Constructor
public function StageProxy(proxyName:String=null, data:Object=null)
{
super(NAME, new StageVO() );
}
/// Return data property cast to proper type
public function get stageVO():StageVO
{
return data as StageVO;
}
}
StageMediator
:
...
public static const NAME:String = 'StageMediator';
private var stageProxy:StageProxy; //reference to Proxie

public function StageMediator( viewComponent:Object )
{
  // stage viewComponent stored in the inherited (super) viewComponent property
   super( NAME, viewComponent );

  // Retrieve reference to frequently consulted Proxies
  stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;

}

EDIT: FIXED
Required
:
override public function initializeNotifier(key:String):void
{
super.initializeNotifier(key);
stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;
}

EDIT 2
A better Fix: (based on Cliff Comments)
:
override public function onRegister():void
{
// Retrieve reference to frequently consulted Proxies
stageProxy = facade.retrieveProxy( StageProxy.NAME ) as StageProxy;
}

T
« Last Edit: April 11, 2008, 08:57:19 by trilec » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: April 11, 2008, 04:32:30 »

As noted in the release notes for MultiCore, you cannot access the facade from within the constructor of a Notifier subclass. The first chance you get to access the Facade is in initializeNotifier. But you could instead wait until onRegister. If you wait until onRegister, you don't have to call super at all.

And although this represents a slight departure from the Standard version practices, it actually sheds light on the fact that calling the facade inside the constructor of a Notifier instance is not really the best practice anyway. Of course onRegister has only just appeared in 2.0 and so the fact that it is the more appropriate place for facade access is just now becoming clear.

Why is onRegister the better place? Because interaction with the Facade should only happen when a Mediator or Proxy is registered, and therefore accessible by other actors via the Facade. For instance a Mediator's interaction with the Facade could lead to a Notification that the Mediator needs to hear. But if it is not yet registered, it could not be notified. Or if a Proxy interacts with the Facade, it could result in another actor trying to retrieve that Proxy, and if it is not yet registered, it cannot be retrieved.

Make sense?
-=Cliff>
Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #2 on: April 11, 2008, 07:52:11 »

Thanks cliff, onRegister sounds a better place.
I left the Post in, for others to see and start a useful dialogue, I have not seen any examples of using "OnRegister" in any standard vision examples as yet.

This point seems a little unclear in the docs, perhaps a good one for the design docs for multicore :-)

Thanks again

T
« Last Edit: April 11, 2008, 08:55:53 by trilec » Logged
landed
Full Member
***
Posts: 37


View Profile Email
« Reply #3 on: August 13, 2009, 07:00:10 »

I'm getting this same error but inside a command class. I cant really understand why the code I inherited is using multicore but it is.

:
public class LoadCommandMessages extends SimpleCommand implements ICommand
{

public function LoadCommandMessages()
{
trace("proxy is "+ facade.retrieveProxy("OdstDataProxy"));
}

}

}
Logged
landed
Full Member
***
Posts: 37


View Profile Email
« Reply #4 on: August 13, 2009, 09:21:56 »

Wasn't running the command's code within the execute method. Doesnt need a constructor seemingly either.
Logged
Pages: [1]
Print