Why can't I inject Mediators into other Actors?

There are two reasons why it is difficult to inject Mediators into other framework actors (Models, Services and/or Commands) in Robotlegs.

On the theoretical side it's not a good idea for your application to know too much about its views. Treating view components as singletons and directly referencing them in your app introduces much tighter coupling than that of simple mediator configuration. Remember that your "view" is just one representation of your application - you should be able to swap it out or add other representations without having to update your "application code".

On the technical side, in Robotlegs v1.0.x:

http://github.com/robotlegs/robotlegs-framework/blob/v1.0.3/src/org...

As you can see, when a Mediator is created (whether manually or automatically), the view component that triggered mediation is temporarily mapped (so that it can be injected into the Mediator) and then unmapped - unfortunately this mapping overwrites any previous mapping for that view component class that you might have had in the injector.

A similar thing happens a little later with Mediator registration:

http://github.com/robotlegs/robotlegs-framework/blob/v1.0.3/src/org...

In this case, the last Mediator instance registered for a particular Mediator class will be mapped into the injector. Not ideal.

The first issue has been mildly addressed in Robotlegs v1.1.x:

http://github.com/robotlegs/robotlegs-framework/blob/v1.1.1/src/org...

When the MediatorMap is instantiated it is handed a "child injector" - an injector that inherits rules from it's parent and can override those rules without affecting it. This allows the MediatorMap to create those old temporary view mappings without overriding any rules you may have mapped in your context injector.

The second issue requires a significant refactoring of the MediatorMap, and will be addressed in the v2.x.x branch.