robotlegs/robotlegs-framework — Issue #67: Bug with Mediator for contextView
Author: 2morrowMan
Created: 2012-02-13 16:01:48+00:00
State: open

```
public class MyAppConfig {
[Inject]
public var mediatorMap:IMediatorMap;

[PostConstruct]
public function configure():void {
mediatorMap.mapView( MyApp ).toMediator( MyAppMediator );
}
}
```

```
context = new Context(
ClassicRobotlegsBundle
MyAppConfig,
this
);
```

MyAppMediator will be never created and does not matter when view was added to stage before config initialize or right after or 10 seconds later.
It is do not works for main context and for any child context.

For now the solution is:

```
public class MyAppConfig {
[Inject]
public var mediatorMap:IMediatorMap;

private var contextView:DisplayObjectContainer;

public function MyAppConfig(contextView:DisplayObjectContainer):void {
this.contextView = contextView;
}

[PostConstruct]
public function configure():void {
mediatorMap.mapView( MyApp ).toMediator( MyAppMediator );

mediatorMap
.getViewMapping(MyApp)
.forMediator(MyAppMediator)
.createMediator(contextView);
}
}
```

```
context = new Context(
ClassicRobotlegsBundle
new MyAppConfig(this),
this
);
```

Thanks to Shaun Smith for help!