Skip to content

Instantly share code, notes, and snippets.

@darscan
Created September 13, 2011 13:58
Show Gist options
  • Select an option

  • Save darscan/1213863 to your computer and use it in GitHub Desktop.

Select an option

Save darscan/1213863 to your computer and use it in GitHub Desktop.

Revisions

  1. darscan created this gist Sep 13, 2011.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    A view Class to mediator Class mapping means that there may be multiple mediator instances for a given view type. How would RL know which instance to inject?

    mediatorMap.mapView(SomeView, SomeMediator);
    ..
    addChild(new SomeView());
    addChild(new SomeView());
    addChild(new SomeView());
    ..
    [Inject]
    public var view:SomeMediator; // which one of the 3 mediator instances should we inject? it makes no sense.

    If you want to inject a mediator, and you know there will only be one instance, you need to map it yourself. You can do that in the mediator's onRegister hook:

    function onRegister():void {
    injector.mapValue(SomeMediator, this);
    }