Connecting Module to Shell – simplified diagram
I had a hard time to understand Flex/PureMVC-Multicore version with Pipes utility especially when simple demos on the web use TeeSplit and Pipe to connect single module to application (diagram at the top-left). It didn’t really make sense to have TeeSplit for only one Pipe/Module. It makes more sense to add Tees(TeeSpit, TeeMerge) only when you go to the next level of having the application collaborate with multiple modules (diagram at the bottom).
Below code shows how to connect single module to application. ShellJunctionMediator.as
package com.mariusht.shellModuleDemo.shell.view { import com.mariusht.shellModuleDemo.common.IPipeAwareModule; import com.mariusht.shellModuleDemo.common.PipeAwareModuleConstants; import com.mariusht.shellModuleDemo.shell.ShellFacade; import org.puremvc.as3.multicore.interfaces.INotification; import org.puremvc.as3.multicore.utilities.pipes.plumbing.Junction; import org.puremvc.as3.multicore.utilities.pipes.plumbing.JunctionMediator; import org.puremvc.as3.multicore.utilities.pipes.plumbing.Pipe; public class ShellJunctionMediator extends JunctionMediator { public static const NAME:String = 'ShellJunctionMediator'; public function ShellJunctionMediator() { super(NAME, new Junction()); } override public function listNotificationInterests():Array { var interests:Array = super.listNotificationInterests(); interests.push(ShellFacade.MODULE_ADDED); return interests; } override public function handleNotification(note:INotification):void { switch(note.getName()) { case ShellFacade.MODULE_ADDED: connectModule(note.getBody() as IPipeAwareModule); break; } } private function connectModule(module:IPipeAwareModule):void { var pipe:Pipe = new Pipe(); junction.registerPipe(PipeAwareModuleConstants.SHELL_TO_MODULE_PIPE, Junction.OUTPUT, pipe); module.acceptInputPipe(PipeAwareModuleConstants.SHELL_TO_MODULE_PIPE, pipe); } } }


Leave a comment