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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Re: Deferred Instantiation... Ughh! on: September 02, 2008, 02:55:33
probably, you didn't get me... My point is "do not create anything until it necessary" :) And this is happens:

1. I press the button in View, which throws Event and this Event is to be catch by Mediator. For example, the application's menu bar with a handler in ApplicationMediator.
2. This mediator uses sendNotification to force Command to do an action.
3. The command tells to the ApplicationMediator to switch to a state 'X' (by using sendNotification) and tries to tell to another Mediator (which is in a pair with a state's view) to do some job (by using sendNotification).

The problem on 3rd step, that the view's internal components are not initialized yet, so they are not available to the view's Mediator. Even more, View's Mediator will not exists because creationComplete on this View is not thrown yet (the view's mediator is created in this event). Looks like, Flex calls creationComplete in the next frame.

At the moment, I do following. I have a copy of such Commands with "initializing" stuff. Inside are only sendNotification to switch a state, registerCommand to reregister the current command to the real one and Application.application.callLater to throw the current notification again. With that, creationComplete handler creates my view's mediator and the real command can do the job than.
The other way would be check in a command, if the required mediator is exists and if not, just call itself later with callLater...
2  Announcements and General Discussion / General Discussion / Re: Deferred Instantiation... Ughh! on: September 02, 2008, 01:24:23
I'm pretty sure, children are simply not exists yet before Flex calls creationComplete. So, onRegister call happens "now", and "creationComplete" call happens later, in the next frame. You create MyComponentMediator in the MainMediator constructor, which in turns calls onRegister. This is "now". "Later", "creationComplete" is called. But the mediator is there already.

I would say, the slacker demo with a deffered instantiation is nice until you need your new mediator immediately, for example in a command, where you first make a notification to AppMediator to switch a state and then wants to notify the new mediator....
Pages: [1]