An AIR 3.7 application demonstrating the use of multiple Contexts with the Robotlegs AS3 micro-architecture - version 2
ActionScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
libs
src
.gitignore
README.md

README.md

robotlegs-bender-modular-air

An AIR 3.7 application demonstrating the use of multiple Contexts with the Robotlegs AS3 micro-architecture - version 2

WIP

Modules, multiple Contexts and the ModularConnector (WIP)

In this demo the Shell loads 2 (Flex) Modules, Module_A and Module_B, and a popup window (Flex TitleWindow), which also loads a module, Module_C.

The Contexts communicate with each other through 2 ‘channels’, a named channel 'A-and-B', and a default channel.

The steps for enabling the multi contextual communication:

First of all, you need a contextView, a Context and the ModularityExtension (included in the MVCSBundle).

contextView

Let’s look at Module A’s root Display Object Container ModuleAView, which will be used as the "contextView" for this Context.


private var _robotlegsContext:ModuleAContext;
private function creationCompleteHandler(event:FlexEvent):void
{
        _robotlegsContext = new ModuleAContext(this);
}

ModuleAContext


public function ModuleAContext(view:DisplayObjectContainer)
{
    context = new Context() //1
        .install(MVCSBundle) //2
        .configure(MediatorsConfig, ModuleConnectorConfig) //3
        .configure(new ContextView(view)); //4
}
  1. creates a Context
  2. installs the ModularityExtension (included in the MVCSBundle already)
  3. configures the communication channels (ModuleConnectorConfig)

ModuleConnectorConfig


moduleConnector.onDefaultChannel()
        .receiveEvent(ModularConnectorEvent.SHELL_TO_MODULES_MESSAGE);
moduleConnector.onChannel('A-and-B')
       .relayEvent(ModularConnectorEvent.A_TO_B_MESSAGE);
moduleConnector.onChannel('A-and-B')
        .receiveEvent(ModularConnectorEvent.B_TO_A_MESSAGE);
  1. provides a contextView (ModuleAView)
  2. dispatch events to other Contexts
    
        dispatch(new ModularConnectorEvent(ModularConnectorEvent.A_TO_B_MESSAGE, event.messagesVO));
        
  3. listen to events from other Contexts
    
        addContextListener(ModularConnectorEvent.B_TO_A_MESSAGE, onMessageReceived, ModularConnectorEvent);

Mediators

Shell, Module A and B Connector Configs

 

 

To be continued...