modules usage

iamable's Avatar

iamable

24 Aug, 2015 10:56 AM

Hey,

currently I woul dlike to start working with modules in robotlegs 2.

In my example this could be a config file loader (e.g. Json file).
It tries to load a config file. if there is no file at the path a message box will be opened and the user is asked to select the config file via file browsing.
the path of that file will be saved in application storage directory and reloaded after restarting the application

That classes are working pretty well but how can I put it in a library as a module which I can reuse?

As far as I understand an example (https://github.com/Ondina/robotlegs2-sketches/blob/fac63ff90f99b2df...) I should have a modules own context, right? And this will have its own mappings, right? But how will I initialize that context?

Is that right?

public class ChildContextTest extends Sprite
{ private var mainContext:MainContext; private var myModuleConfig:MyModuleConfig;

    public function ChildContextTest()
    {
        mainContext = new MainContext(this);
        myModuleConfig = new MyModuleConfig(this);

        var mainView:MainView = new MainView();
        addChild(mainView);
    }
}
  1. Support Staff 1 Posted by Ondina D.F. on 24 Aug, 2015 11:33 AM

    Ondina D.F.'s Avatar

    Hi,

    the example you mentioned was using an old extension for modular communication (ScopedEventDispatcherExtension)

    The ScopedEventDispatcherExtension extension has been replaced by the Modularity Extension in a later release of robotlegs 2
    ( https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...)

    An example for Flex and AIR projects using the new extension:

    https://github.com/Ondina/robotlegs-bender-modular-air
    https://github.com/Ondina/robotlegs-bender-modular-air/blob/master/...

    And here is a version for as3 projects, that also loads an external module that uses a modular library:

    https://github.com/Ondina/robotlegs-bender-as3-modular-example
    https://github.com/Ondina/robotlegs-bender-as3-modular-example/blob...

    Please take a look at the examples, try them out and read the readme files.
    Let me know if you still need help after that.

    Ondina

  2. 2 Posted by iamable on 24 Aug, 2015 12:25 PM

    iamable's Avatar

    perfect! thank you. that's what I was searching for

  3. 3 Posted by iamable on 24 Aug, 2015 12:50 PM

    iamable's Avatar

    unfortunately the nested context never initializes the MediatorConfig. Can you tell me why?

    public function MyModuleContext(view:DisplayObjectContainer)
    { trace("module context");

            context = new Context()
                .install(MVCSBundle, EventDispatcherExtension)
                .configure(MyModuleMediatorsConfig)
                .configure(new ContextView(view));
        }
    

    the modules context seems to work. I got the trace:
    170 DEBUG Context-1-c0 [object ViewManagerBasedExistenceWatcher] Adding context existence event listener to container [object MyModuleView]

    170 DEBUG Context-1-c0 [object ConfigManager] Now initializing. Instantiating config class [class MyModuleMediatorsConfig]

    170 DEBUG Context-1-c0 [object ConfigManager] Now initializing. Injecting into config object [object ContextView]

    170 INFO Context-1-c0 Context-1-c0 Initialize complete

    but the mediator isn't connected to the view.
    also the trace of the Mediator config isnt logged

    public class MyModuleMediatorsConfig
    { [Inject] public var mediatorMap:IMediatorMap;

        public function configure():void
        {
            trace("modules mediator config");
    
            mediatorMap.map(MyModuleView).toMediator(MyModuleMediator);
        }
    }
    
  4. 4 Posted by iamable on 24 Aug, 2015 12:53 PM

    iamable's Avatar

    ooohh sorry. It didn't implements IConfig. Sorry for spam.

  5. Support Staff 5 Posted by Ondina D.F. on 25 Aug, 2015 12:34 PM

    Ondina D.F.'s Avatar

    hehe, no problem:)

  6. Ondina D.F. closed this discussion on 25 Aug, 2015 12:34 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