views:

70

answers:

1

Hi all

i have one question about pureMvc.

i uew pureMvc to build an engine, in the engine init part i have an requirement

1) moduleA must init firt

2) moduleB , moduleC need init after moduleA init complate.

3) moduleD need init after moduleB & moduleC init complate.

4) moduleA , moduleB , moduleC , moduleD all extends Proxy beacuse the four system all need to send notifiation ,but no need to listen it.

but to fit for the requirement i can't use command to do it , beacuse they have ini order and also they need to remember current state(ex: moudelB is init Complate but moudleC is not init complate then can't init moudleD) but command is stateless.

the best way i think is use one Mediator to do it, beacuse it can both listen and send notifiation.

my question is :

1) is this a good way to use one Mediator to do it ?

2) if use Mediator is good way, then when it hear first moduleA is init complate

registerCommand(FIRST_MODULE_INIT_COMPLATE , initStepTwoCommand);
sendNotification(FIRST_MODULE_INIT_COMPLATE);
removeCommand(FIRST_MODULE_INIT_COMPLATE);

need to do things like that way or just do the inti logic in the Mediator ?

thanks

A: 

There's a utility called StartUpManager, which should handle this problem. It let's you define loading dependencies so mediators/proxies aren't registered before the required data is available. Here's the link

http://trac.puremvc.org/Utility%5FAS3%5FStartupManager

rlayte
thanks a lot , i will take a look that code.
Tunied