Skip to content
Derilas edited this page Jan 23, 2012 · 3 revisions

CoreModule

To init framework we create class that extends CoreModule. We send main class object to constructor. We override startup() to start working.

Set up.

in CoreModule sub-class or in Command sub-class you can set up your application.

Models:

modelMap.mapClass(modelClass:Class, injectClass:Class = null, name:String = "");

modelMap.mapObject(modelObject:Object, injectClass:Class = null, name:String = "");

modelMap.unmapClass(modelClass:Class, type:String = "");

Mediators:

mediatorMap.mapMediator(viewClass:Class, mediatorClass:Class);

mediatorMap.unmapMediator(viewClass:Class);

mediatorMap.mediate(viewObject:Object);

mediatorMap.unmediate(viewObject:Object);

Commands:

commandMap.map(type:String, commandClass:Class);

commandMap.unmap(type:String, commandClass:Class);

Sending messages:

CoreModele's, Command's, Mediator's, Module's can all send messages.

params is any object that will be passed to Commands execute() function, or to any handler listening for this message.

sendMessage(type:String, params:Object=null);

Listening for messages:

Only commands and mediators can listen for messages.

Maped commands are executed.

Mediators can add(remove) handle functios that are called then message is sent:

addHandler(type:String, handler:Function);

removeHandler(type:String, handler:Function);

handler functions must get single param:Object parameter. (you can type it to whatever you want.)

Controller:

Your commands must extend Command class. They must have execute() function. execute() function must get single param:Object parameter. (you can type it to whatever you want.)

Commands is automaticaly executed to maped messages. or manualy with this command. (CoreModule's and Command's can use it...)

commandMap.execute(commandClass:Class, params:Object = null);

They can be injected with models with [Inject] metatag. (variable MUST be public)

[Inject] public var sampleEmptyModel:SampleEmptyModel;

Mediators:

Mediator must extend Mediator class.

They can be injected with models with [Inject] metatag. (variable MUST be public)

[Inject] public var sampleEmptyModel:SampleEmptyModel;

Also they injected with view object they are mediating.

[Inject] public var view:PureLegsSample;

Mediators overrides onRegister and onRemove functios to init and dispose them.

Models:

Must extend Model class.

They can be injected with models with [Inject] metatag. (variable MUST be public)

[Inject] public var sampleEmptyModel:SampleEmptyModel;

Clone this wiki locally