RL2, iOS - Creating children views that have their own mediator

zmaldonado's Avatar


27 Jun, 2014 03:46 PM

Hi there,

I've been using Robotlegs 2 for a while now and have gone through all of the documentation and can't seem to find a way of dealing with my problem.

For simplicity sake, I have a parent with a mediator that I need to dynamically populate with child (which require their own mediators). Normally, I'd solve this problem by having the a child factory from a module. My problem is, and I know this isn't exactly a RL2 problem, that I can't use modules for iOS. This is kind of a roadblock and I feel like it should be doable, but I've yet to find good documentation about dealing with module-like things for iOS.

Thanks in advance!

  1. 1 Posted by zmaldonado on 27 Jun, 2014 03:52 PM

    zmaldonado's Avatar

    I was using the AcmeWidgetFactory example (http://examples.robotlegs.org/widgetfactory/index.html) as a basis for my project, but 1) that's using RL1 and 2) using modules.

  2. Support Staff 2 Posted by Ondina D.F. on 28 Jun, 2014 11:54 AM

    Ondina D.F.'s Avatar


    Regarding swfs for iOS mobile, see if you can find anything useful in the following articles:

    Release Notes | Flash Player® 11.7 AIR® 3.7 - Externally hosting secondary swf files (iOS):

    "Starting with AIR 3.7, application developers will be able to host their secondary SWFs on an external server and load them on demand as per their application logic." see here: http://blogs.adobe.com/airodynamics/2013/03/08/external-hosting-of-...

    I agree with Alex Harui - see last comment on this thread:

    Other workarounds:


    As a side note: in case you just want to have multiple contexts inside of an application, assuming that the file size doesn't matter that much, you can use any display object as a contextView, not just Flex Modules, to create as many contexts as you need. But, you probably already knew that:)

    If you're asking how to use the Modularity Extension for robotlegs 2, just let me know, and I'll give you more info about it or links to examples.


  3. 3 Posted by zmaldonado on 30 Jun, 2014 02:49 PM

    zmaldonado's Avatar

    Thanks Ondina for the response!

    Seems like secondary SWFs isn't the way to go, as in, they aren't reliable, they aren't secure, they require loading from an external server which doesn't really make sense speed wise for what I need, and they would probably be a headache to implement.

    In terms of multiple contexts, yes, that seems more feasible. Pretty much I need to setup N number of child objects that have their own mediators, commands, and I guess context.

    As for the Modularity Extension (which I've seen your example of https://github.com/Ondina/robotlegs-bender-modular-air) It works great, but once again, it relies on the use of s:Module and swf loading. Is there any way around this?

    Thank you again!

  4. Support Staff 4 Posted by Ondina D.F. on 30 Jun, 2014 03:10 PM

    Ondina D.F.'s Avatar

    You're welcome!

    As I said, you can use any display object instead of a Flex Module. All you need to do is to add the contextView of each child context to the stage, in the parent-contextView or in one of its sub-views. When you remove the child-contextView from stage, its context will be destroyed. So, in my example, you just need to replace the Module container with a display object of your choice, and instead of using module loader or swf loader, you simply add the view to the stage. The Modularity extension needs a contextView in order to work, but it doesn't have to be a Flex Module.

    Let me know if it works for you. If it doesn't, I'll try to find some time to modify my example, so it would work without swfs.

  5. 5 Posted by zmaldonado on 30 Jun, 2014 03:22 PM

    zmaldonado's Avatar

    Oh, I see what you are saying! Sorry about that. Glad you took the time to explain that. I'll work on this and let you know how it goes.


  6. Support Staff 6 Posted by Ondina D.F. on 30 Jun, 2014 03:41 PM

    Ondina D.F.'s Avatar

    Yes, let me know how it goes. It might be useful for other iOS developers, as well.

  7. 7 Posted by zmaldonado on 30 Jun, 2014 08:43 PM

    zmaldonado's Avatar

    Works great! I found a similar thread to what I was trying to accomplish http://forum.starling-framework.org/topic/screennavigator-and-mvc-f... that deals with the issue in the comments ("The ScreenNavigator has its own mediator, and the Screen's mediator dispatches an event that the ScreenNavigator's mediator can listen for.")

    Way more comfortable with Contexts and configs overall. I really like how you setup up your config files, Ondina (https://github.com/Ondina/robotlegs-bender-modular-air/tree/master/...) Very clean and easy to work with.

  8. Support Staff 8 Posted by Ondina D.F. on 01 Jul, 2014 01:02 PM

    Ondina D.F.'s Avatar

    Hi Zack,

    Oh, I'm glad that my example is useful and that you like it:) Thank you.
    Yes, configs classes are cool.
    With robotlegs 1, we used commands for the bootstrapping /configuration process. You can do that with rl2, as well, but rl2's configs are much more convenient. You don't need any mappings (commands had to be mapped to events..), thus you write less code. They are 'clean', because the mappings are grouped together in categories, mediators, models, services..etc, thus easier to manage in a large application. In a small application, you could perform the mappings inside of a single config.

    I've read the Starling discussion. If I understand correctly, you are actually after a way of managing the navigation between different functional parts of your app. You can have multiple contexts, each functional area with its own context, if you want. But, that's not mandatory. You can treat each functional area like a module, in the sense that it is pretty much self-contained, even if it doesn't have a separate context. In case the functional areas are sharing some of the classes, Models, custom events, services, you create a 'commons' / 'shared' or whatever package for them, which would be the equivalent of a library project in a flex-modular application.
    Am I'm right in thinking that you need a solution for navigating and structuring/organizing your pseudo-modules, rather than creating multiple contexts? If so, and if you need help with this, you may want to go into details about your use case.


  9. Ondina D.F. closed this discussion on 15 Jul, 2014 07:15 AM.

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

Keyboard shortcuts


? 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