Mediators instantiation priority

Boboy's Avatar


23 Mar, 2011 12:12 PM


I'm facing a problem I can't resolve.
I'm using RL with AS3-Signals in a small module which is part of a big project. I have a main mediator associated with a main view which are called by the master as the entry point for my module. I use this mediator as a local Context meaning that I map mediators to views (sub-components in my module).

The problem is that I map a bunch of mediators to my already-on-stage views, and when RL registers every mediator (once I add my main view to the ContextView), I need to be able to know when the sub-view-mediators are ALL registered. The fact is that I have a first view component which acts as a tabNavigator, and its Mediator is registered before the others so when it dispatch his signal (in the onRegister() method), the others (which are supposed to listen to the same injected signal) are not yet registered and thus, not able to react to the signal.

So, I wonder if there is a simple way of being notified when all those mediators are ready so I can dispatch the signal and be sure they listen properly.
Thanks for your work and your help!


  1. 1 Posted by Michal Wroblews... on 23 Mar, 2011 12:29 PM

    Michal Wroblewski's Avatar

    Hi Boboy,

    You can create a command that dispatches when one of your mediators you need is registered. Command saves in another model that view was created. If Model checks that all of mediators you need are created then it can dispatch the signal you want to dispatch when all mediators are ready.

    Other method is to create a Context when all your components are ready and added. And after all mappings you dispatch StartupSignal/Command.


  2. 2 Posted by Boboy on 23 Mar, 2011 12:48 PM

    Boboy's Avatar

    Hi Michal,

    Thanks for the fast reply!
    I came to the same conclusion about the use of a command which would keep a trace of each registered mediator, I was naively hoping for an alternative :)

    About your second option, I heard before that it's better to avoid using multiple contexts when we can, so I'm a bit afraid in my case :)

    Anyways, thank you for your advice! I'm going to stick with the "count" solution which seems "less worse" in my sense!


  3. 3 Posted by Michal Wroblews... on 23 Mar, 2011 12:51 PM

    Michal Wroblewski's Avatar

    I thought about instantiating of your Context when all of your views are already added to stage.


  4. 4 Posted by Stray on 23 Mar, 2011 12:57 PM

    Stray's Avatar

    Michal's suggestion is the one I use.

    I actually have a utility service that I re-use for this purpose - when I initiate it I tell it how many contacts to expect and the event to wire to. When done, it fires an 'all done' event.


  5. Stray closed this discussion on 03 Apr, 2011 11:09 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