Injection Mapping with the MediatorMap Class
The MediatorMap class implements IMediatorMap, which provides methods for mapping your mediators to views and registering them for injection.
mapView(viewClassOrName:*, mediatorClass:Class, injectViewAs:Class = null, autoCreate:Boolean = true, autoRemove:Boolean = true)
mapView accepts a view class, MyAwesomeWidget, or a fully qualified class name for a view, com.me.app.view.components::MyAwesomeWidget as the first parameter. The second parameter is the Mediator class that will mediate the view component.
The optional injectViewAs parameter is useful when you want to inject the view into the mediator as an interface or abstract class - by default the view is injected by its concrete type.
The two additional parameters autoCreate and autoRemove are boolean switches that provide convenient automatic mediator management.
//someplace in your application where mapping/configuration occurs mediatorMap.mapView(MyAwesomeWidget, MyAwesomeWidgetMediator);
//somewhere inside of the contextView's display list var myAwesomeWidget:MyAwesomeWidget = new MyAwesomeWidget(); this.addChild(myAwesomeWidget); //the ADDED_TO_STAGE event is dispatched, which triggers the view component to be mediated
This approach utilizes the automated mediation. Manual mediation, and a more in-depth look at this process will be covered later in the Mediators section.