Modular using robotlegs 2 with no views

matej's Avatar

matej

21 Dec, 2012 07:11 AM

Hello,

Is it possible to use context inheritance (parent, child) without using views, because from what i saw modular extension relies on modular views.

For example, to build a library in robotlegs that will be used inside other applications and to have an option for that library to be independent for AS3/FLEX projects or to be able to communicate with parent context both ways.

The reason for this is in my use of flash first I build base and then just later the views come as independent units.

I hope the question is clear enough :)

  1. Support Staff 1 Posted by Ondina D.F. on 22 Dec, 2012 10:34 AM

    Ondina D.F.'s Avatar

    Hi Matej,

    Sorry for the late response.

    The question is clear enough:)

    -If the module you’re loading is extending spark.modules.Module and you add the moduleLoader to the stage, even if it doesn’t contain visual components, the module’s context will inherit everything it needs from the parent context

    -If you can’t add it to the stage, you can add the moduleLoader or moduleLoader.child to the SystemManager, and before doing so, you make use of the viewManager.addContainer(moduleLoader) [robotlegs.bender.extensions.viewManager]

    -If you don’t want to add the module to the stage or to the system manager, you can pass the parent injector on to it through an interface:

    (moduleLoader.child as ISomeInterface).initContext(parentInjector);

    or just the shared event dispatcher, depending on your needs.

    Personally, I don’t know of any other ways of creating a viewless context. Shaun would be the one to shed more light on this;)

    Ondina

  2. Support Staff 2 Posted by Shaun Smith on 22 Dec, 2012 12:42 PM

    Shaun Smith's Avatar

    Hello Matej

    The Modularity extension does indeed rely on views on the Display List. However, at the end of the day, all this extension does is link the child's injector.parent to the parent's injector:

    https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...

    Or:

    https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...

    If you have your own way to determine context "hierarchy" that is not based on the display list structure, you can write your own extension to do the same (linking the injectors). Just try to make sure that the link has been made before the child context has been initialized.

    Of course, you don't have to write an extension to do this, you could just do it manually, but it would probably be a good idea if it's something you plan on using a lot.

    Hope that helps

  3. Support Staff 3 Posted by Shaun Smith on 22 Dec, 2012 12:45 PM

    Shaun Smith's Avatar

    This does make me wonder if there should be a more "official" way to do this. Perhaps there should be a method on the Context's API, something like: parentContext.addChild(childContext)?

  4. 4 Posted by Gustavo on 22 Dec, 2012 01:00 PM

    Gustavo's Avatar

    Hi Ondina,

    I would like to add to Matej's question. Imagine I have a Library that provides an interface to do some fileBrowsing manipulation, such as saving, deleting or else. Meaning that it uses through AIR the native windows for browsing selecting files renaming etc...

    Let's also say that this library is independant and it built on Robotlegs2. As in the case of Matej this library has no class extending the displayObject.

    Now!, I have 2 cases of pure AS3 (no flex) applications, one built on RL2 and the other has no RL.

    In the case of the project without RL I will just create a context in the Libb. No modularity needed. But in the second case, which would be the proper way to pass the context of the application to the lib expecting modularity?

    I imagine they are already out there many modules/libs that are/can_be built on RL2 and to profit of this modularity.

  5. 5 Posted by Gustavo on 22 Dec, 2012 01:07 PM

    Gustavo's Avatar

    Hi Shaun,

    I most definitely believe this is NECESSARY.

    More and more me, as I presume more AS developers, am working with AIR and ANE's and I believe that standardization would be well received in this case.

  6. Support Staff 6 Posted by Ondina D.F. on 23 Dec, 2012 11:49 AM

    Ondina D.F.'s Avatar

    Hi Gustavo,

    Sorry for responding late, again, but since the world didn’t end on Friday, my list of things to do before the end of the year didn’t disappear either ;-)

    In the case of the project without RL I will just create a context in the Libb. No modularity needed. But in the second case, which would be the proper way to pass the context of the application to the lib expecting modularity?

    If you mean loading another RL2 application into the current one, the external application would be treated like any other module (swf).
    Of course there are differences between loading an application and loading a module, but they are not related to robotlegs.
    Framework specific is that both contexts, in the main app and in the external one, should install the MVCSBundle(which includes the ModularitExtension) and the ScopedEventDispatcherExtension, so they can communicate through a shared event dispatcher.

    An application isn’t “view-less”, because it has to have a root display object, either Flex-Application or as3-Sprite.

    You said „pass the context of the application to the lib expecting modularity”. Here, I don’t know exactly what you mean :). Two applications sharing the same context? Or each application with its own context and just communicating through a shared event dispatcher?

    Perhaps there should be a method on the Context's API, something like: parentContext.addChild(childContext)?

    @Shaun I also think this would be a good idea!

    Ondina

  7. Support Staff 7 Posted by Shaun Smith on 23 Dec, 2012 07:39 PM

    Shaun Smith's Avatar

    Cool, thanks for the feedback, new beta version on the way...

  8. Support Staff 8 Posted by Ondina D.F. on 24 Dec, 2012 03:42 PM

    Ondina D.F.'s Avatar

    That’s great, Shaun :) Thank you!!

    For everyone interested, here are the links to the new beta:
    https://github.com/robotlegs/robotlegs-framework/tree/master/src

    and tests:
    https://github.com/robotlegs/robotlegs-framework/tree/master/test

  9. Support Staff 9 Posted by Shaun Smith on 03 Jan, 2013 07:47 PM

    Shaun Smith's Avatar

    Hi, I'm closing this thread for now. Please re-open, or create a new thread, if you have other questions.

  10. Shaun Smith closed this discussion on 03 Jan, 2013 07:47 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