Pure MVC is a Classic MVC Design meta-pattern.
Like MVC pattern Pure-MVC also have 3 Singletons - Model, View and Controller which are called Core Actors and Pure-MVC has another Singleton called Facade, which is to communicate with Core Actors(Model,View & Controller).
Architecture Diagram:
1. The Model caches named references to Proxies, which expose an API for manipulating the Data Model (including data retrieved from remote services).
2. The View primarily caches named references to Mediators, which adapt and steward the View Components that make up the user interface.
3. The Controller maintains named mappings to Command classes, which are stateless, and only created when needed.
4. The Façade initializes and caches the Core actors (Model, View and Controller), and provides a single place to access all of their public methods.
-> Observers & Notifications: are introduced in PureMVC to avoid the access or dependency of the flash events.
-> Notifications can be used to trigger the Command execution.
-> Mediator can send, declare interest in and receive Notifications.
-> Proxies send but not receive Notifications.
Facade:
Facade brokers your request to the Model,view and controller, so that your code doesn't need to import more classes and you don't need to work with them individually.
-> The Facade class automatically instantiate the core MVC Singletons in its constructor.
-> Concrete Facade is then used to access and notify the Commands, Mediators and Proxies that do the actual work of the system.
ApplicationFacade.as
package com.myapp;
{
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.pattern.facade.*;
public class ApplicationFacade extends Facade implements IFacade
{
public static const STARTUP:String="Startup";
public static const LOGIN:String="Login";
public static instance:ApplicationFacade =null;
public static function getInstance():ApplicationFacade {
if(instance==null){
instance = new ApplicationFacade();
}
return instance as ApplicaitonFacade;
}
override protected function initializeController(){
super.initializeController();
//Register the commands
registerCommand(STARTUP,StartupCommand);
}
public function startup(app:MyApp){
sendNotification(STARTUP,app);
}
}
}
Notifications:
PureMVC implements the Observer pattern so that the core actors and their collaborators can communicate in a loosely-coupled way and without platform dependency.
-> Notificaiton may have an optional "Body" which can be any actionscript object.
-> Notification also have an optional "Type" that can be used by the Notification recipient as a discriminator.
Like MVC pattern Pure-MVC also have 3 Singletons - Model, View and Controller which are called Core Actors and Pure-MVC has another Singleton called Facade, which is to communicate with Core Actors(Model,View & Controller).
Architecture Diagram:
1. The Model caches named references to Proxies, which expose an API for manipulating the Data Model (including data retrieved from remote services).
2. The View primarily caches named references to Mediators, which adapt and steward the View Components that make up the user interface.
3. The Controller maintains named mappings to Command classes, which are stateless, and only created when needed.
4. The Façade initializes and caches the Core actors (Model, View and Controller), and provides a single place to access all of their public methods.
-> Observers & Notifications: are introduced in PureMVC to avoid the access or dependency of the flash events.
-> Notifications can be used to trigger the Command execution.
-> Mediator can send, declare interest in and receive Notifications.
-> Proxies send but not receive Notifications.
Facade:
Facade brokers your request to the Model,view and controller, so that your code doesn't need to import more classes and you don't need to work with them individually.
-> The Facade class automatically instantiate the core MVC Singletons in its constructor.
-> Concrete Facade is then used to access and notify the Commands, Mediators and Proxies that do the actual work of the system.
ApplicationFacade.as
package com.myapp;
{
import org.puremvc.as3.interfaces.*;
import org.puremvc.as3.pattern.facade.*;
public class ApplicationFacade extends Facade implements IFacade
{
public static const STARTUP:String="Startup";
public static const LOGIN:String="Login";
public static instance:ApplicationFacade =null;
public static function getInstance():ApplicationFacade {
if(instance==null){
instance = new ApplicationFacade();
}
return instance as ApplicaitonFacade;
}
override protected function initializeController(){
super.initializeController();
//Register the commands
registerCommand(STARTUP,StartupCommand);
}
public function startup(app:MyApp){
sendNotification(STARTUP,app);
}
}
}
Notifications:
PureMVC implements the Observer pattern so that the core actors and their collaborators can communicate in a loosely-coupled way and without platform dependency.
-> Notificaiton may have an optional "Body" which can be any actionscript object.
-> Notification also have an optional "Type" that can be used by the Notification recipient as a discriminator.

No comments:
Post a Comment