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: Question for "resolver add child"?  (Read 8384 times)
marks416
Sr. Member
****
Posts: 52


View Profile Email
« on: February 23, 2009, 01:54:13 »

Hi,

I read the demo 'resolver_add_child'. This demo show me how to do 'Reflexive Mediator Registration' with states.

The application build a new instance of  'ConfirmMediator' when I open the view of the 'confirm'.

Many instances of 'ConfirmMediator' will be built when I open the 'confirm view' many times.

In my case, I like to use 'Reflexive Mediator Registration' but I only need one instaNce of Mediator built at first time and it create by something like
"registerMediator(new ConfirmMediator(resolve(application)..confirm))".

I do not want the app to create other instance of the same Mediator when I visit the 'view'. I only have one instance for each mediator so I just call database once when I use a function in the mediator.

Please give me a guide for this.

Thanks for your help


Mark

Logged
marks416
Sr. Member
****
Posts: 52


View Profile Email
« Reply #1 on: February 23, 2009, 02:07:40 »

Hi,

I use the same logic of the demo to my application.

my problem is same function is called many times after I visit the "view" many times.

Please give me a idea to fix my code.

Thanks

Mark
Logged
Darshan Sawardekar
Sr. Member
****
Posts: 85


View Profile Email
« Reply #2 on: February 23, 2009, 10:14:37 »

Hey Mark,

I think you forgot the attachment.

peace,
darshan
Logged
marks416
Sr. Member
****
Posts: 52


View Profile Email
« Reply #3 on: February 24, 2009, 07:50:28 »

Hi Darshan,

Thanks for your help.

In the attached code, the debug console will print out one "call mediator" when I click the "need to register" link once.

But I only need the mediator is called once and only register with "registermediator" statement.I do not want the view create a new instance of mediator when I open the view.

Can you tell me how to do this?

Thanks

Mark
Logged
Darshan Sawardekar
Sr. Member
****
Posts: 85


View Profile Email
« Reply #4 on: February 25, 2009, 02:26:26 »

Hi Mark,

I am not completely clear about your question. If I understand you right, you want the mediator the ConfirmMediator to be registered with PureMVC only once. This registration only happens when the confirm form item is added to the application. The registration and return links basically add/remove this form item using Flex states.

With the code,
:
registerMediator(new ConfirmMediator(resolve(application)..confirm));

you are indicating that the ConfirmMediator should be registered when the confirm component is created. Correspondingly the mediator is removed when the confirm component is removed. A new instance of the ConfirmMediator is only registered when the confirm component. This demo shows that if at any point in time you remove your viewComponent the mediator is removed, and if you later add it back the Mediator for it gets registered also. So if you don't removed the confirm component the registration and mediator will be registered only once.

peace,
darshan
Logged
marks416
Sr. Member
****
Posts: 52


View Profile Email
« Reply #5 on: February 26, 2009, 09:51:19 »

Hi,

I figure it out. the mediator create when the view create and I have to remove the mediator the the view is gone.

Thanks

Mark
Logged
Pages: [1]
Print