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  PureMVC Manifold / MultiCore Version / Is MultiCore necessary for use of Flex Modules? on: April 16, 2008, 01:00:35
Hi

I've used the standard AS3 PureMVC framework for a few projects now but am just starting another project now where I want to make use of Flex modules to be able to divide up my code/components into a load only when required basis. Also I might want to make some modules available to some users but not others.

I want my Flex modules that get loaded into the application to each be controlled by a single mediator - again the mediator code should only get loaded in with the module.

This is one of the benefits I understood the multiicore version of PureMVC would offer.

In the modularity demo I can see that each module/widget has it's own ApplicationFacade. This isn't necessary for my project, I just want to be able to hook in loaded modules into the PureMVC app and to be able to listen and send notifications from/to the main app and then be unloaded if necessary.

I've managed to achieve this by setting my module(s) to implement a custom interface - IPureMVCModule (which extends IUIComponent). When the module's creation complete event is triggered it then adds it's self to the main application like this:

:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" visible="false"
implements="net.editioninteractive.modules.interfaces.IPureMVCModule"
  creationComplete="facade.loadModule(new ModuleDTO(this,ModuleViewMediator))" >
<mx:Script>
<![CDATA[
import net.app.player.view.modules.ModuleViewMediator;
import net.app.player.model.vo.ModuleDTO;
import net.app.player.ApplicationFacade;
public static const NAME:String = 'MainApp';
protected var facade:ApplicationFacade = ApplicationFacade.getInstance( NAME );
]]>
</mx:Script>


<mx:Panel title="My Panel" width="100%" height="100%" />
</mx:Module>

Where 'MainApp' is the key of the already loaded ApplicationFacade.

Inside the main ApplicationFacade my custome loadModule method looks like this:

:
        public function loadModule( data:ModuleDTO ):void
        {
       
        sendNotification( MODULE_INIT, data );
        }

Where MODULE_INIT is mapped to a command that registers a new instance of the mediator class with the new module as the viewComponent, passed through in the custom ModuleDTO dto.

This works - so I'm pleased about that.

The main reason for my post is for 2 reasons:

1) Would my use of PureMVC above be considered good/bad practice?

2) I could achieve the above with the standard PureMVC framework in a similar way couldn't I? Ie, MultiCore isn't necessary for use of PureMVC with modules?

Thanks for the help and the framework - really enjoy working in this way once I got to grips with it!

Pages: [1]