Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
April 28, 2017, 05:10:17 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: Attaching pipes to modules  (Read 3333 times)
4ucai
Jr. Member
**
Posts: 17


View Profile
« on: November 30, 2011, 01:26:39 AM »

Hello,

I recently started studying the pipes utility. However, I stumble some rocks ahead.
I have this module cores( which are individual swf ), both will be loaded to a main swf.
I was successful in communicating the two modules using interface but I believe using pipes
will provide me greater flexibility as I introduce more modules.
I can't seem to know when to attach the pipe fittings to the modules. Both of my modules now
have a ModuleJunctionMediator, I still cant grasp the idea on how to connect the pipes to the
module.

Regards
Michael
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2865



View Profile WWW
« Reply #1 on: November 30, 2011, 08:18:10 AM »

You should make your module implement an IPipeAwareModule interface that gives it methods for accepting an input pipe or an output pipe. These are sent by notification to the internal JunctionMediator which handles adding them.

You could have a look at source code for the PipeWorks demo here:
http://trac.puremvc.org/Demo_AS3_MultiCore_Flex_PipeWorks

Jens Krause has a good demo here:
http://www.websector.de/blog/2008/06/21/a-basic-puremvc-multicore-as3-example-using-pipes-utility-and-modules/

Joel Hooks' great demo combining pipes and the state machine:
http://joelhooks.com/2009/05/18/piping-the-machine-puremvc-multicore-with-pipes-and-the-finite-state-machine-fsm/

Frederic Saunier has another good pipes demo here:
http://www.tekool.net/blog/2009/06/14/puremvc_flex_modules_and_pipes/

Hopefully these will get you started and show you a few different takes on the mechanics of plumbing your app with Pipes.

Cheers,
-=Cliff>
Logged
4ucai
Jr. Member
**
Posts: 17


View Profile
« Reply #2 on: December 01, 2011, 06:28:58 AM »

Thanks for the quick replay cliff, the examples you've given were really helpful. I just need some more time to practice and test the pipes examples.
Logged
4ucai
Jr. Member
**
Posts: 17


View Profile
« Reply #3 on: December 03, 2011, 03:26:52 AM »

Hello Cliff,

I just successfully implemented the pipes utility on my shell and modules. However, my module and shell both have an exported class/AS linkage with the same name. After i loaded the module to the shell, the loaded module now uses the exported class from the shell. I tried renaming the exported class and it worked well. However, it's quite cumbersome to rename the modules exported class that conflicts the shell. Is there anyway to fix this?

Also, what's the best way to handle loading of modules. Should i place it in a LoadModuleCommand or a LoadModuleMediator?

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2865



View Profile WWW
« Reply #4 on: December 03, 2011, 10:42:19 AM »

Quote
After i loaded the module to the shell, the loaded module now uses the exported class from the shell. I tried renaming the exported class and it worked well. However, it's quite cumbersome to rename the modules exported class that conflicts the shell. Is there anyway to fix this?
Yes, just package them differently.

I don't know what your conflicting class name is, but the only reason it can be conflicting is if it lives in the same package node in both the shell and module projects. So just make sure your packaging is unique for every core of your app, be it a module or the shell.

For instance:

Shell classes (in Shell project):
Code:
com.me.myapp.shell.controller.*
com.me.myapp.shell.model.*
com.me.myapp.shell.view.*

TortoiseModule classes (in Tortoise project):
Code:
com.me.myapp.tortoise.controller.*
com.me.myapp.tortoise.model.*
com.me.myapp.tortoise.view.*

HareModule classes (in Hare project):
Code:
com.me.myapp.hare.controller.*
com.me.myapp.hare.model.*
com.me.myapp.hare.view.*

Common classes (separate library, made available to all projects):
Code:
com.me.myapp.common.controller.*
com.me.myapp.common.model.*
com.me.myapp.common.view.*

Quote
Also, what's the best way to handle loading of modules. Should i place it in a LoadModuleCommand or a LoadModuleMediator?
There are lots of ways to do this.

Commands are for business logic and should be shielded from the boundaries of the app (i.e., services and UI) as much as possible. However, it is short-lived, and for a transitory task like loading a module and perhaps mediating it, a Command is an acceptable place.

You could write a simple Proxy to load the module and send it off in a note to be mediated once it's been loaded. The Proxy usually shouldn't be involved in any way with visual componentry, but in the case that it is treated essentially like data, and no operations are performed on it beyond fetching, it is an acceptable responsibility for the Proxy role.

You could use the Loadup[1] utility, but that might be overkill if you don't really have any other assets to load you'd have to look into it and see what you think. It treats a swf as just another asset type, and gives you the benefit of retry policies and error handling being taken care of.

A Mediator can work well too, but be careful of overloading it with lots of logic for plumbing and the like. You would at most want to send it a note saying to load a module, then it would send out success or failure notes that are handled by a Command that does the plumbing.

-=Cliff>

PureMVC Loadup Utility
http://trac.puremvc.org/Utility_AS3_Loadup
« Last Edit: December 03, 2011, 11:18:06 AM by puremvc » Logged
4ucai
Jr. Member
**
Posts: 17


View Profile
« Reply #5 on: December 04, 2011, 04:35:14 AM »

Hello Cliff,

Thanks for the reply and the solution you provided.

I'll take a look at the "Utility_AS3_Loadup" after I get to familiarize myself more on the pipes utility.
Logged
Pages: [1]
Print
Jump to: