I had a chance to work with Cliff Hall’s PureMVC ‘Pipes’ utility this week. Highly recommended.
If your interested in utilizing modules in your PureMVC projects, you owe it to yourself to take a look at the Pipes utility.
What’s needed to integrate a module?
The requirements are very light. You module should:
Implement IPipeAware
Create a JunctionMediator.
Thats it.
I took some time and refactored the Mortgage app to use the Pipes utility.
I ran into a small bump after unloading widgets. If I unloaded a widget and then clicked “Quotes”, I still received a loan quote from what should have been an unloaded module. I ended up subclassing the ‘TeeSplit’ class to allow disconnecting a single known IPipeFitting. This allowed me to ‘cleanup’ the dynamic modules properly.
That aside, the utility was very easy to work with – the plumbing metaphors really make things clear.
I found the utility to be quite flexible as well. I just wrapped up working on some utility classes that allow modules to load modules that load modules etc. Getting this to work with direct core to core communications was at best ‘messy.’ Using the pipes made this very clean and simple.
Lorenzo
March 4, 2009 at 4:39 am
Hi Joshua,
can you explain with a simple example the module to module communication?
thanks in advance
Regards
Lorenzo
Joshua
March 4, 2009 at 9:06 am
Lorenzo, how you architect the communication depends on your use case. You could send your messages ‘up’ to the main app (from the loaded swf) and back down to the other loaded swfs (see http://www.joshuaostrom.com/2008/06/17/pipe-demo-mortgage-app/ for an example). You could also communicate directly, although if your app grows too much (loading numerous modules) I’d recommend a common message ‘bus’ over point-to-point communication flows
Lorenzo
March 23, 2009 at 10:42 am
Hi Joshua,
thanks for the reply…
i would create a small application, like a portal, where modules are loaded and unloaded run-time.
in the app if two modules are “compatibles” they can pass data each other..
so could you suggest me the best way to rich modules to modules communication..
in the past week i’ve read about pureMVC and pipes utility…i think it could be the right way to follow (even if it’s more difficult), instead of using interface and references (as suggested into the adobe flex doc).
thanks again
Lorenzo
Joshua
March 25, 2009 at 10:50 pm
Using the flex doc approach is valid in that you define an interface for the clients to implement. This defines a ‘contract’ that the module will then fulfill.
Regardless of which approach you use, you can have the loaded app send a message up to the main app, and have the app route the message back down to the loaded modules.
If your not familiar w/PureMVC I’d suggest writing a small proof of concept app to get this wired up. Once you have that you can determine if you’d like to implement as-is or move over to PureMVC (pipes).
Josh