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 [2]
Print
Author Topic: PureMVC + Modules  (Read 22779 times)
tjiddy
Jr. Member
**
Posts: 10


View Profile Email
« Reply #15 on: January 23, 2008, 10:27:26 »

You could use the 'type' parameter to the notification to hold the name of the module to load and let the body be the reference to the ModuleLoader to load said module into.

The way I got around it was inside my controller, I loaded the module using ModuleManager.getModule(), registered the module with the moduleFacade, then sent a LOAD_MODULE_SUCCESS notification with the IModuleInfo as the body.  The mediator that sent the request notification originally, is listening for that notification and then can do something like:

:
app.container.addChild( (notification.getBody() as IModuleInfo).factory.create() as Module2 );

--The positive, no moduleloaders to pass around, clean separation of controller from view components.

--The negative - The same notification is sent regardless of which module was loaded making loading multiple modules simultaniously ugly. (the mediators would have to inspect the module, or the controller could add the module name in the notifications type field.
« Last Edit: January 23, 2008, 10:34:26 by tjiddy » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #16 on: January 23, 2008, 12:29:24 »

Whan you say 'in the controller' are you referring to a Command executed by the Controller, or did you actually extend Controller and add this functionality?

-=Cliff>
Logged
tjiddy
Jr. Member
**
Posts: 10


View Profile Email
« Reply #17 on: January 23, 2008, 03:47:38 »

sorry ... in the command
Logged
Lord
Newbie
*
Posts: 4


View Profile Email
« Reply #18 on: March 20, 2009, 04:50:02 »

Hi all,

this approach seems to fit very well with my expectations..

a question for rockhowse...

in your sample i found TestMessageController class that listens for notifications...so i would modify this class to change view within a module...for example a module sends a notification (note and body)...then an other module takes the body and changes his views..(e.g. data provided into a datagrid). have i to implement a mediator in the module? how to rich this goal?

finally, if modules are unloaded is there a right way to follow?

Thanks in advance... ;)

Reagards Lorenzo
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #19 on: March 20, 2009, 06:12:39 »

Don't send notifications between modules. You can't guarantee both modules define the same note constant to mean the same thing. Notes are handy to toss around inside a single core (the shell or a module) where all the actors see the same static constant, but you need to either pass a strongly typed object between cores using PipeMessages (see PipeWorks demo) or make interface calls (see Modularity demo).

Those demos, for ease of use pack the modules and shell and common code all in one project and instantiate the modules rater than loading them, but in the real world these will be separate projects.

-=Cliff>
Logged
Lord
Newbie
*
Posts: 4


View Profile Email
« Reply #20 on: March 20, 2009, 08:22:41 »

Hi Cliff,

thanks for the reply...

pureMVC is very very very cool work...congratulations...but i make difficult to understand it!!!  :'(

i would create an application that can loads modules. In particular i would have an inter module communication...

can you give me you some suggestions?

Thanks again
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #21 on: March 21, 2009, 06:54:25 »

Yes.Firstly to ease the learning cureve I suggest reading the Framework Overview and Best Practices docs (under the 'Docs' tab of the site). While they are based on the Standard Version, the differences to MultiCore are very slight. The roles, responsibilities and collaborations of the actors are the same.

As for intermodule communication this is a unique capability of MultiCore, and there are 2 possibilities. The first is demonstrated by the Modularity demo and that is interface communication. Each module and the shell app (collectively referred to as 'cores' since each represents a separate set of MVCF actors. Each core implements one or more interfaces exposed for synchronous calls made by other cores.
The other method is asynchronous/anonymous messages passed via pipeline to other cores. This is afforded by the Pipes utility and illustrated by the
Pipeworks demo.

You can mix and match thes methods as needed within the same application as needed.

Loading and unloading of modules is beyond the scope of those demos, but on the AS3 MultiCore menu you'll find a link to a great tutorial on module loading/unloading with Garbage Collection, and a functioning demo, done by Simon Bailey.

-=Cliff>
Logged
Pages: 1 [2]
Print