Does every module 'needs' to use ModuleContext

Meg's Avatar

Meg

29 Sep, 2011 01:23 PM

Does every module 'needs' to use ModuleContext. My application was earlier a flex app and i was using a context and everything worked like a charm. Now I converted my app to a module and an external app loads my module (which stills uses Context and not ModuleContext) and I see errors like IMediatorMap not found, LoggerEvent not found etc. Basically injections are not happening. This is urgent and I am stuck.

ReferenceError: Error #1065: Variable IInjector is not defined.

at flash.system::ApplicationDomain/getDefinition()
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/initializeInjection()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:58]
at org.swiftsuspenders.injectionpoints::InjectionPoint()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/InjectionPoint.as:19]
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:31]
at org.swiftsuspenders::Injector/getInjectionPoints()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/Injector.as:271]
at org.swiftsuspenders::Injector/instantiate()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/Injector.as:130]
at org.robotlegs.base::CommandMap/execute()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:168]
at org.robotlegs.base::CommandMap/routeEventToCommand()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:223]
at Function/<anonymous>()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:98]
at flash.events::EventDispatcher/dispatchEventFunction()

Do I need to convert Context to Module Context and change event dispatcher to module dispatcher in my entire app? Or is there any way I could pass the application domian to this existing context? Please help me, this is urgent. Below find some code snippets:

MyModule.mxml
public function OnCreationComplete():void{

myContext = new MyContext(this); }

MyContext.as
public class MyContext extends Context
{ public function MyContext(contextView:DisplayObjectContainer){
super(contextView);
}

override public function startup():void
{ injector.mapSingletonOf(IAppService, AppService);
. . . // bunch of mappings for model,biew,contreoller goes here super.startup();
}

Thanks a lot,
Meg

  1. 1 Posted by Stray on 29 Sep, 2011 01:35 PM

    Stray's Avatar

    Hi Meg,

    yes - your loaded Modules need to use a ModuleContext not a normal Context, as this provides the extra functionality required by modules.

    In RL2 this won't be necessary, but for RL1, it is.

    Stray

  2. 2 Posted by Meg on 29 Sep, 2011 01:38 PM

    Meg's Avatar

    Stray,

    Thanks a lot for the prompt reply. I saw few applications which were using modules but still using Context (and not ModuleContext). That is why I am confused.

    Also, If I start using ModuleContext, do I also have to replace all eventDispatchers.dispatchEvent calls by moduleDispatchers? Also how about overriding few methods for injection. Are they required? What other changes do you think are needed, if they are at top of your head.

    Thanks a lot,
    Meg

  3. 3 Posted by Meg on 29 Sep, 2011 01:44 PM

    Meg's Avatar

    Also, I am looking at the WidgetModuleContext in the example app under RL exampled, example uses Context here as opposed to ModuleContext. Why is that?

  4. 4 Posted by Stray on 29 Sep, 2011 01:46 PM

    Stray's Avatar

    Hi Meg,

    There are some good examples and tutorials on the web that cover the basics:

    http://www.digitaldogbyte.com/2010/08/17/robotlegs-modular-utilities-tutorial/

    and

    http://joelhooks.com/2010/05/02/modular-robotlegs/

    would be a good place to start.

    Personally I use the moduleMediator class to relay events into and out of the modules. This means that my code doesn't need to change for inside / outside a modular environment. I like that approach, though I know some other people prefer the convenience of using the moduleDispatcher directly.

    Stray

  5. Support Staff 5 Posted by Ondina D.F. on 01 Nov, 2011 05:33 PM

    Ondina D.F.'s Avatar

    If you need more help with this, please feel free to re-open this discussion. Please open new threads for new issues.
    Thanks!
    Ondina

  6. Ondina D.F. closed this discussion on 01 Nov, 2011 05:33 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac