Packagemvcexpress.mvc
Classpublic class Mediator
InheritanceMediator Inheritance Object

Mediates single view object. Main responsibility of mediator is to send messages from framework to view, and receive events from view and send them to framework as messages.

Can get proxies injected. Can send message strings. (then user interacts with the view, or to inform about view state changes, like animation end) Can handle message strings. (handles data change or other framework constants) Can handle view events.



Public Properties
 PropertyDefined By
  mediatorMap : IMediatorMap
Handles application mediators.
Mediator
  proxyMap : ProxyMapForMediator
Interface to work with proxies.
Mediator
Protected Methods
 MethodDefined By
  
addHandler(type:String, handler:Function):void
Adds handle function to be called then message of given type is sent.
Mediator
  
addListener(viewObject:IEventDispatcher, type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with viewObject, so that the listener is executed then event is dispatched.
Mediator
  
hasHandler(type:String, handler:Function):Boolean
Checks if mediator has handler for message type.
Mediator
  
onRegister():void
Then viewObject is mediated by this mediator - it is inited first and then this function is called.
Mediator
  
onRemove():void
Then viewObject is unmediated by this mediator - this function is called first and then mediator is removed.
Mediator
  
Remove all handle functions created by this mediator, internal module handlers AND scoped handlers.
Mediator
  
Removes all listeners created by mediators addEventListener() function.
Mediator
  
removeHandler(type:String, handler:Function):void
Removes handle function from message of given type.
Mediator
  
removeListener(viewObject:IEventDispatcher, type:String, listener:Function, useCapture:Boolean = false):void
Removes an event listener from the viewObject.
Mediator
  
sendMessage(type:String, params:Object = null):void
Sends a message with optional params object inside of current module.
Mediator
Property Detail
mediatorMapproperty
public var mediatorMap:IMediatorMap

Handles application mediators.

proxyMapproperty 
public var proxyMap:ProxyMapForMediator

Interface to work with proxies.

Method Detail
addHandler()method
protected function addHandler(type:String, handler:Function):void

Adds handle function to be called then message of given type is sent.

Parameters

type:String — message type for handle function to react to.
 
handler:Function — function that will be called then needed message is sent. this function must expect one parameter. (you can set your custom type for this param object, or leave it as Object)

addListener()method 
protected function addListener(viewObject:IEventDispatcher, type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Registers an event listener object with viewObject, so that the listener is executed then event is dispatched.

Parameters

viewObject:IEventDispatcher — view object that can dispatch events.
 
type:String — The type of event.
 
listener:Function — The listener function that processes the event. This function must accept an event object as its only parameter and must return nothing, as this example shows: function(event:Event):void The function can have any name.
 
useCapture:Boolean (default = false) — Determines whether the listener works in the capture phase or the target and bubbling phases.
 
priority:int (default = 0) — The priority level of the event listener. Priorities are designated by a 32-bit integer. The higher the number, the higher the priority. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak. A strong reference (the default) prevents your listener from being garbage-collected. A weak reference does not.

hasHandler()method 
protected function hasHandler(type:String, handler:Function):Boolean

Checks if mediator has handler for message type.

Parameters

type:String — message type for handle function to react to.
 
handler:Function — handler function.

Returns
Boolean — true if mediator has a handler.
onRegister()method 
protected function onRegister():void

Then viewObject is mediated by this mediator - it is inited first and then this function is called.

onRemove()method 
protected function onRemove():void

Then viewObject is unmediated by this mediator - this function is called first and then mediator is removed.

removeAllHandlers()method 
protected function removeAllHandlers():void

Remove all handle functions created by this mediator, internal module handlers AND scoped handlers. Automatically called then mediator is removed(unmediated) by framework. (You don't have to put it in mediators onRemove() function.)

removeAllListeners()method 
protected function removeAllListeners():void

Removes all listeners created by mediators addEventListener() function. WARNING: It will NOT remove events that was added normally with viewObject.addEventListener() function. Automatically called then mediator is removed(unmediated) by framework. (You don't have to put it in mediators onRemove() function.)

removeHandler()method 
protected function removeHandler(type:String, handler:Function):void

Removes handle function from message of given type. Then Mediator is removed(unmediated) all message handlers are automatically removed by framework.

Parameters

type:String — message type that was set for handle function to react to.
 
handler:Function — function that was set to react to message.

removeListener()method 
protected function removeListener(viewObject:IEventDispatcher, type:String, listener:Function, useCapture:Boolean = false):void

Removes an event listener from the viewObject. Then Mediator is removed(unmediated) all event handlers added with addListener() function will be automatically removed by framework.

Parameters

viewObject:IEventDispatcher — view object that can dispatch events.
 
type:String — The type of event.
 
listener:Function — The listener object to remove.
 
useCapture:Boolean (default = false) — Specifies whether the listener was registered for the capture phase or the target and bubbling phases.

sendMessage()method 
protected function sendMessage(type:String, params:Object = null):void

Sends a message with optional params object inside of current module.

Parameters

type:String — type of the message for Commands or Mediator's handle function to react to.
 
params:Object (default = null) — Object that will be passed to Command execute() function or to handle functions.