Package | com.soma.core.mediator |
Class | public class Mediator |
Inheritance | Mediator ![]() ![]() |
Implements | IMediator |
Author: Romuald Quantin - www.soundstep.com
Resources: http://www.soundstep.com/downloads/somacore
Actionscript version: 3.0
Copyright: Mozilla Public License 1.1 (MPL 1.1) http://www.opensource.org/licenses/mozilla1.1.php
A Mediator is a class that extends a wire and has a relation one-to-one with a view. A mediator can be created with the injection enabled or disabled.
The first step is to map a view class to a mediator class, and everytime a view is added to a display list, a mediator for this view is automatically instantiated by the framework.
The mediator instance will automatically be destroyed by the framework when the view it represents will be removed from the display list.
See also
Property | Defined By | ||
---|---|---|---|
![]() | injector : ISomaInjector [read-only] | Wire | |
![]() | instance : ISoma
Retrieves the instance of the framework. | Wire | |
![]() | mediators : SomaMediators [read-only] | Wire | |
![]() | stage : Stage [read-only]
Get the stage that has been registered to the framework. | Wire | |
viewComponent : Object
View that has been mapped to the mediator instance. | Mediator |
Property | Defined By | ||
---|---|---|---|
![]() | _name : String
Name of the wire. | Wire | |
_viewComponent : Object
View that has been mapped to the mediator instance. | Mediator |
Method | Defined By | ||
---|---|---|---|
Mediator(name:String = null)
Create an instance of a Mediator class. | Mediator | ||
![]() | addCommand(commandName:String, command:Class):void
Registers a command to the framework. | Wire | |
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | Wire | |
![]() |
Registers a model to the framework. | Wire | |
![]() | addView(viewName:String, view:Object):Object
Registers a view to the framework. | Wire | |
![]() |
Registers a wire to the framework. | Wire | |
creationComplete():void
Method that can you can override, called when if the view is part of the Flex Framework (not used for a pure AS3 view). | Mediator | ||
![]() | dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow. | Wire | |
![]() | dispose():void
Method that can you can override, called when the wire has been removed from the framework. | Wire | |
![]() | getCommand(commandName:String):Class
Retrieves the command class that has been registered with a command name. | Wire | |
![]() | getCommands():Array
Retrieves all the command names (event type) that have been registered to the framework. | Wire | |
![]() |
Retrieves the last sequence command that has been instantiated in the framework. | Wire | |
![]() |
Retrieves the model instance that has been registered using its name. | Wire | |
![]() | getModels():Dictionary
Retrieves all the model instances that have been registered to the framework. | Wire | |
![]() | getName():String
Retrieves the name of the wire. | Wire | |
![]() | getRunningSequencers():Array
Retrieves all the sequence command instances that are running. | Wire | |
![]() | getSequencer(event:Event):ISequenceCommand
Retrieves the sequence command instance using an event instance that has been created from this sequence command. | Wire | |
![]() | getView(viewName:String):Object
Retrieves the view instance that has been registered using its name. | Wire | |
![]() | getViews():Dictionary
Retrieves all the view instances that have been registered to the framework. | Wire | |
![]() |
Retrieves the wire instance that has been registered using its name. | Wire | |
![]() | getWires():Dictionary
Retrieves all the wire instances that have been registered to the framework. | Wire | |
![]() | hasCommand(commandName:String):Boolean
Indicates wether a command has been registered to the framework. | Wire | |
![]() | hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | Wire | |
![]() | hasModel(modelName:String):Boolean
Indicates wether a model has been registered to the framework. | Wire | |
![]() | hasView(viewName:String):Boolean
Indicates wether a view has been registered to the framework. | Wire | |
![]() | hasWire(wireName:String):Boolean
Indicates wether a wire has been registered to the framework. | Wire | |
![]() | initialize():void
Method that can you can override, called when the wire has been registered to the framework. | Wire | |
![]() | isPartOfASequence(event:Event):Boolean
Indicates wether an event has been instantiated from a ISequenceCommand class. | Wire | |
![]() | postConstruct():void | Wire | |
![]() | removeCommand(commandName:String):void
Removes a command from the framework. | Wire | |
![]() | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object. | Wire | |
![]() | removeModel(modelName:String):void
Removes a model from the framework and call the dispose method of this model. | Wire | |
![]() | removeView(viewName:String):void
Removes a view from the framework and call the (optional) dispose method of this view. | Wire | |
![]() | removeWire(wireName:String):void
Removes a wire from the framework and call the dispose method of this wire. | Wire | |
![]() | setName(name:String):void
Sets the name of the wire. | Wire | |
![]() | stopAllSequencers():void
Stops all the sequence command instances that are running. | Wire | |
![]() | stopSequencer(sequencer:ISequenceCommand):Boolean
Stops a sequence command using the sequence command instance itself. | Wire | |
![]() | stopSequencerWithEvent(event:Event):Boolean
Stops a sequence command using an event instance that has been created from this sequence command. | Wire | |
![]() | willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | Wire |
_viewComponent | property |
protected var _viewComponent:Object
View that has been mapped to the mediator instance.
viewComponent | property |
viewComponent:Object
View that has been mapped to the mediator instance.
public function get viewComponent():Object
public function set viewComponent(value:Object):void
Mediator | () | Constructor |
public function Mediator(name:String = null)
Create an instance of a Mediator class. The Mediator class should be extended and is usually automatically created (and removed) by the framework.
Parametersname:String (default = null ) — Name of the wire.
|
creationComplete | () | method |
public function creationComplete():void
Method that can you can override, called when if the view is part of the Flex Framework (not used for a pure AS3 view).
package { import com.soma.core.interfaces.IMediator; import com.soma.core.mediator.Mediator; public class MyViewMediator extends Mediator implements IMediator { [Inject] public var myView:MyView; override public function initialize():void { // called when the mediator has been created and registered to the framework trace(myView == viewComponent); } override public function dispose():void { // called when the mediator has been destroyed by the framework } } }
mediators.mapView(MyView, MyViewMediator);
mediators.removeMapping(MyView);
var mediator:MyViewMediator = mediators.getMediatorByView(view) as MyViewMediator;
mediators.mapView(MyView, MyViewMediator); var view:MyView = new MyView(); myDisplayObjectContainer.addChild(view); // mediator instance created var mediator:MyViewMediator = mediators.getMediatorByView(view) as MyViewMediator; trace(mediators.hasMediator(view));