SlideShare uma empresa Scribd logo
1 de 17
PureMVC
PureMVC Framework


The PureMVC framework has a very narrow goal. That is to help
you separate your application’s coding interests into three discrete
tiers: M odel, View and Controller.

This separation is very important in the building of scalable and
maintainable applications.

In this implementation of the classic MVC Design metapattern,
these three tiers of the application are governed by three
Singletons ( class where only one instance may be created)
             a
called simply Model, View and Controller.
Together, they are referred to as the ‘Core actors’.

A fourth Singleton, the Façade simplifies development by providing
a single interface for communication with the Core actors.
PureMVC Framework
PureMVC Architecture



M odel & Proxies
The Model simply caches named references to Proxies. Proxy
code manipulates the data model, communicating with remote
services if need be to persist or retrieve it.
This results in portable Model tier code.

View & M ediators
The View primarily caches named references to Mediators.
Mediator code stewards View Components, adding event
listeners, sending and receiving notifications to and from the
rest of the system on their behalf and directly manipulating their
state.
This separates the View definition from the logic that controls it.
PureMVC Architecture




Controller & Commands

The Controller maintains named mappings to Command
classes, which are stateless, and only created when needed.
Commands may retrieve and interact with Proxies, send
Notifications, execute other Commands, and are often used to
orchestrate complex or system-  wide activities such as
application startup and shutdown.
They are the home of your application’s Business Logic.
PureMVC Architecture




Façade & Core

The Façade, another Singleton, initializes the Core actors
(Model, View and Controller) and provides a single place to
                              ,
access all of their public methods.
By extending the Façade, your application gets all the benefits
of Core actors without having to import and work with them
directly. You will implement a concrete Façade for your
application only once and it is simply done.
Proxies, Mediators and Commands may then use your
application’s concrete Façade in order to access and
communicate with each other.
PureMVC Architecture



Observers & Notifications

PureMVC applications may run in environments without access
to Flash’s Event and EventDispatcher classes, so the
framework implement s an Obser ver not ificat ion scheme for
communication between the Core MVC actors and other parts
of the system in a loosely- coupled way.
You need not be concerned about the details of the PureMVC
Observer/  Notification implementation; it is internal to the
framework.
You will use a simple method to send Notifications
from Proxies, Mediators, Commands and the Façade itself that
doesn’t even require you to create a Notification instance.
PureMVC Architecture




  Notifications can be used to trigger command execution.

Commands are mapped to Notification names in your concrete
Façade, and are automatically executed by the Controller when
their mapped Notifications are sent.
Commands typically orchestrate complex interaction between
the interests of the View and Model while knowing as little about
each as possible.
PureMVC Architecture




  Mediators Send, Declare Interest In and Receive Notifications

When they are registered with the View, Mediators are
interrogated as to their Notification interests by having their
listNotifications method called, and they must return an array
of Notification names they are interested in.
Later, when a Notification by the same name is sent by any
actor in the system, interested Mediators will be notified by
having their handleNotification method called and being passed
a reference to the Notification.
PureMVC Architecture




         Proxies Send, But Do Not Receive Notifications



Proxies may send Notifications for various reasons, such as a
remote service Proxy alerting the system that it has received a
result or a Proxy whose data has been updated sending a
change Notification.
ApplicationFacade

//A concrete Facade for MyApp
public class ApplicationFacade extends Façade implements IFacade
{
     // Define Notification name constants
     public static const STARTUP:String = quot;startupquot;;
     public static const LOGIN:String = quot;loginquot;;

    // Singleton ApplicationFacade Factory Method
    public static function getInstance() : ApplicationFacade
      {
         if ( instance == null ) instance = new ApplicationFacade( );
         return instance as ApplicationFacade;
    }

    // Register Commands with the Controller
    override protected function initializeController( ) : void
    {
         super.initializeController();
         registerCommand( STARTUP, StartupCommand );
         registerCommand( LOGIN, LoginCommand );
         registerCommand( LoginProxy.LOGIN_SUCCESS, GetPrefsCommand );
    }

    // Startup the PureMVC apparatus, passing in a reference to the app public
    public startup( app:MyApp ) : void
    {
         sendNotification( STARTUP, app );
    }
}
Main Application




<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<mx:Application xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
        creationComplete=quot;façade.startup(this)”>

    <mx:Script>
        <![CDATA[
            // Get the ApplicationFacade
            import com.me.myapp.ApplicationFacade;

            private var facade:ApplicationFacade = ApplicationFacade.getInstance();
        ]]>
    </mx:Script>

    <!—Rest of display hierarchy defined here -->

</mx:Application>
Startup Command


This is a MacroCommand that adds two sub-commands, which are
executed in FIFO order when the MacroCommand is executed.

     package com.me.myapp.controller
     {
         import org.puremvc.as3.interfaces.*;
         import org.puremvc.as3.patterns.command.*;
         import com.me.myapp.controller.*;

         // A MacroCommand executed when the application starts.
         public class StartupCommand extends MacroCommand
         {
             // Initialize the MacroCommand by adding its subcommands.
             override protected function initializeMacroCommand() : void
             {
                 addSubCommand( ModelPrepCommand );
                 addSubCommand( ViewPrepCommand );
             }
         }
     }
ModelPrepCommand


Preparing the Model is usually a simple matter of creating and
registering all the Proxies the system will need at startup.
    package com.me.myapp.controller
    {
        import org.puremvc.as3.interfaces.*;
        import org.puremvc.as3.patterns.observer.*;
        import org.puremvc.as3.patterns.command.*;
        import com.me.myapp.*;
        import com.me.myapp.model.*;
        // Create and register Proxies with the Model.
        public class ModelPrepCommand extends SimpleCommand
        {
        // Called by the MacroCommand
            override public function execute( note : INotification ) : void
            {
                 facade.registerProxy( new SearchProxy() );
                 facade.registerProxy( new PrefsProxy() );
                 facade.registerProxy( new UsersProxy() );
            }
        }
    }
ViewPrepCommand

This is a SimpleCommand that prepares the View for use. It is the
last of the previous MacroCommand’s subcommands, and so, is
executed last.
    package com.me.myapp.controller
    {
        import org.puremvc.as3.interfaces.*;
        import org.puremvc.as3.patterns.observer.*;
        import org.puremvc.as3.patterns.command.*;
        import com.me.myapp.*;
        import com.me.myapp.view.*;
        // Create and register Mediators with the View.
        public class ViewPrepCommand extends SimpleCommand
        {
            override public function execute( note : INotification ) : void
            {
                 var app:MyApp = note.getBody() as MyApp;
                 facade.registerMediator( new ApplicationMediator( app ) );
            }
        }
    }
Sample Proxy


// A proxy to log the user in
public class LoginProxy extends Proxy implements IProxy {

    private var loginService: RemoteObject;
    public function LoginProxy () {
        super( NAME, new LoginVO ( ) );
        loginService = new RemoteObject();
        loginService.source = quot;LoginServicequot;;
        logi nService.destination = quot;GenericDestinationquot;;
        loginService.addEventListener( FaultEvent.FAULT, onFault );
        loginService.login.addEventListener( ResultEvent.RESULT, onResult );
    }
    // Cast data object with implicit getter
    public function get loginVO( ) : LoginVO {
        return data as LoginVO;
    }
    // The user is logged in if the login VO contains an auth token
    public function get loggedIn():Boolean {
        return ( authToken != null );
    }
    // Subsequent calls to services after login must include the auth token
    public function get authToken():String {
        return loginVO.authToken;
    }
Sample ViewMediator

public class LoginPanelMediator extends Mediator implements IMediator
{
    public static const NAME:String = 'LoginPanelMediator';

    public function LoginPanelMediator( viewComponent:LoginPanel )
    {
        super( NAME, viewComponent );
        LoginPanel.addEventListener( LoginPanel.TRY_LOGIN, onTryLogin );
    }
    // List Notification Interests
    override public function listNotificationInterests( ) : Array
    {
        return [
            LoginProxy.LOGIN_FAILED,
            LoginProxy.LOGIN_SUCCESS
            ];
    }
    // Handle Notifications
    override public function handleNotification( note:INotification ):void
    {
        switch ( note.getName() ) {
            case LoginProxy.LOGIN_FAILED:
            LoginPanel.loginVO = new LoginVO( );
            loginPanel.loginStatus = LoginPanel.NOT_LOGGED_IN;
            Break;
        ...

Mais conteúdo relacionado

Mais procurados

Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desaijinaldesailive
 
Reactive Application Using METEOR
Reactive Application Using METEORReactive Application Using METEOR
Reactive Application Using METEORNodeXperts
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)Roger Kitain
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questionsAkhil Mittal
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programmingKuntal Bhowmick
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVCJohn Lewis
 
Multiple Submit Button Test App
Multiple Submit Button Test AppMultiple Submit Button Test App
Multiple Submit Button Test AppPeeyush Ranjan
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCJohn Lewis
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog SampleSkills Matter
 
ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basicspetrov
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 

Mais procurados (20)

Spring Actionscript at Devoxx
Spring Actionscript at DevoxxSpring Actionscript at Devoxx
Spring Actionscript at Devoxx
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Reactive Application Using METEOR
Reactive Application Using METEORReactive Application Using METEOR
Reactive Application Using METEOR
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
 
Multiple Submit Button Test App
Multiple Submit Button Test AppMultiple Submit Button Test App
Multiple Submit Button Test App
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
 
Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)
 
my accadanic project ppt
my accadanic project pptmy accadanic project ppt
my accadanic project ppt
 
ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basics
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 

Destaque

Certificado de trabajo
Certificado  de trabajoCertificado  de trabajo
Certificado de trabajoMarcia Crespo
 
Solicitud paz y salvo
Solicitud paz y salvoSolicitud paz y salvo
Solicitud paz y salvoYenci Camargo
 
Certificado laboral
Certificado laboralCertificado laboral
Certificado laboralZeBaz Garcia
 
Constancia de trabajo 2 elver
Constancia de trabajo 2 elverConstancia de trabajo 2 elver
Constancia de trabajo 2 elvering_eliali4748
 
Formato de paz y salvo
Formato de paz y salvoFormato de paz y salvo
Formato de paz y salvolinajimenez30
 
Nomina Y Liquidaciones
Nomina Y LiquidacionesNomina Y Liquidaciones
Nomina Y Liquidacionesbetsy ruiz
 
Constancia de trabajo gobierno regional de pasco
Constancia de trabajo gobierno regional de pascoConstancia de trabajo gobierno regional de pasco
Constancia de trabajo gobierno regional de pascoRichard Flores Atachagua
 
A carta de demissão de Gaspar !
A carta de demissão de Gaspar !A carta de demissão de Gaspar !
A carta de demissão de Gaspar !Umberto Pacheco
 
4C Consulting Breakfast Seminar - Survival Analysis
4C Consulting Breakfast Seminar - Survival Analysis4C Consulting Breakfast Seminar - Survival Analysis
4C Consulting Breakfast Seminar - Survival Analysis4C
 
Recomendacion laboral rsa wib
Recomendacion laboral rsa wibRecomendacion laboral rsa wib
Recomendacion laboral rsa wibBe Ready
 
Carta de Declaración de Ingresos
Carta de Declaración de IngresosCarta de Declaración de Ingresos
Carta de Declaración de IngresosJavier Montes
 
Carta de recomendacion laboral
Carta de recomendacion laboralCarta de recomendacion laboral
Carta de recomendacion laboralelguar
 
Solicitud Al Alcalde
Solicitud Al AlcaldeSolicitud Al Alcalde
Solicitud Al AlcaldeDeush1
 
Certificado de honorabilidad
Certificado de honorabilidadCertificado de honorabilidad
Certificado de honorabilidadMarcia Crespo
 

Destaque (20)

Certificado de trabajo
Certificado  de trabajoCertificado  de trabajo
Certificado de trabajo
 
Constancia de trabajo
Constancia de trabajoConstancia de trabajo
Constancia de trabajo
 
Modelo constancia de trabajoS
Modelo constancia de trabajoSModelo constancia de trabajoS
Modelo constancia de trabajoS
 
Solicitud paz y salvo
Solicitud paz y salvoSolicitud paz y salvo
Solicitud paz y salvo
 
Certificado laboral
Certificado laboralCertificado laboral
Certificado laboral
 
Constancia de trabajo 2 elver
Constancia de trabajo 2 elverConstancia de trabajo 2 elver
Constancia de trabajo 2 elver
 
Formato de paz y salvo
Formato de paz y salvoFormato de paz y salvo
Formato de paz y salvo
 
Nomina Y Liquidaciones
Nomina Y LiquidacionesNomina Y Liquidaciones
Nomina Y Liquidaciones
 
Solicitudes
SolicitudesSolicitudes
Solicitudes
 
modelos de solicitudes
modelos de solicitudesmodelos de solicitudes
modelos de solicitudes
 
Constancia de trabajo 2
Constancia de trabajo 2Constancia de trabajo 2
Constancia de trabajo 2
 
Constancia de trabajo gobierno regional de pasco
Constancia de trabajo gobierno regional de pascoConstancia de trabajo gobierno regional de pasco
Constancia de trabajo gobierno regional de pasco
 
A carta de demissão de Gaspar !
A carta de demissão de Gaspar !A carta de demissão de Gaspar !
A carta de demissão de Gaspar !
 
4C Consulting Breakfast Seminar - Survival Analysis
4C Consulting Breakfast Seminar - Survival Analysis4C Consulting Breakfast Seminar - Survival Analysis
4C Consulting Breakfast Seminar - Survival Analysis
 
Recomendacion laboral rsa wib
Recomendacion laboral rsa wibRecomendacion laboral rsa wib
Recomendacion laboral rsa wib
 
Carta de Declaración de Ingresos
Carta de Declaración de IngresosCarta de Declaración de Ingresos
Carta de Declaración de Ingresos
 
Carta de recomendacion laboral
Carta de recomendacion laboralCarta de recomendacion laboral
Carta de recomendacion laboral
 
Solicitud Al Alcalde
Solicitud Al AlcaldeSolicitud Al Alcalde
Solicitud Al Alcalde
 
Grado paz y salvo
Grado paz y salvoGrado paz y salvo
Grado paz y salvo
 
Certificado de honorabilidad
Certificado de honorabilidadCertificado de honorabilidad
Certificado de honorabilidad
 

Semelhante a Architecting ActionScript 3 applications using PureMVC

關於 Puremvc Command 的那點事
關於 Puremvc Command 的那點事關於 Puremvc Command 的那點事
關於 Puremvc Command 的那點事Erin Lin
 
The Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionThe Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionFITC
 
WPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaWPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaRainer Stropek
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...LogeekNightUkraine
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]Mohamed Abdeen
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Lou Sacco
 
15minutesintroductiontoappdynamics1.pdf
15minutesintroductiontoappdynamics1.pdf15minutesintroductiontoappdynamics1.pdf
15minutesintroductiontoappdynamics1.pdfAnuSelvaraj2
 
Application Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The UglyApplication Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The UglyRichard Lord
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
Spring mvc my Faviourite Slide
Spring mvc my Faviourite SlideSpring mvc my Faviourite Slide
Spring mvc my Faviourite SlideDaniel Adenew
 
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013Raimundas Banevičius
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard DevelopersHenri Bergius
 

Semelhante a Architecting ActionScript 3 applications using PureMVC (20)

關於 Puremvc Command 的那點事
關於 Puremvc Command 的那點事關於 Puremvc Command 的那點事
關於 Puremvc Command 的那點事
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
The Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionThe Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework Evolution
 
WPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaWPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA Austria
 
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
 
C#on linux
C#on linuxC#on linux
C#on linux
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014
 
15minutesintroductiontoappdynamics1.pdf
15minutesintroductiontoappdynamics1.pdf15minutesintroductiontoappdynamics1.pdf
15minutesintroductiontoappdynamics1.pdf
 
Application Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The UglyApplication Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The Ugly
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
 
Spring mvc my Faviourite Slide
Spring mvc my Faviourite SlideSpring mvc my Faviourite Slide
Spring mvc my Faviourite Slide
 
Robotlegs Extensions
Robotlegs ExtensionsRobotlegs Extensions
Robotlegs Extensions
 
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
 

Mais de marcocasario

HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...
HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...
HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...marcocasario
 
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...marcocasario
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeomarcocasario
 
HTML5 cross-platform and device development: web app per tutti gli schermi
HTML5 cross-platform and device development: web app per tutti gli schermiHTML5 cross-platform and device development: web app per tutti gli schermi
HTML5 cross-platform and device development: web app per tutti gli schermimarcocasario
 
Applicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore RomeoApplicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore Romeomarcocasario
 
Mobile HTML5 Web Apps - Codemotion 2012
Mobile HTML5 Web Apps - Codemotion 2012Mobile HTML5 Web Apps - Codemotion 2012
Mobile HTML5 Web Apps - Codemotion 2012marcocasario
 
Enterprise Spring and Flex applications
Enterprise Spring and Flex applicationsEnterprise Spring and Flex applications
Enterprise Spring and Flex applicationsmarcocasario
 
Local Persistent data with ActionScript 3 and AIR
Local Persistent data with ActionScript 3 and AIRLocal Persistent data with ActionScript 3 and AIR
Local Persistent data with ActionScript 3 and AIRmarcocasario
 
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3marcocasario
 
Adobe TechConnection: Flex Best Practices
Adobe TechConnection: Flex Best PracticesAdobe TechConnection: Flex Best Practices
Adobe TechConnection: Flex Best Practicesmarcocasario
 
We make it RIA at Comtaste
We make it RIA at ComtasteWe make it RIA at Comtaste
We make it RIA at Comtastemarcocasario
 
Flex and AIR User Interface Design Showcases and Examples
Flex and AIR User Interface Design Showcases and ExamplesFlex and AIR User Interface Design Showcases and Examples
Flex and AIR User Interface Design Showcases and Examplesmarcocasario
 
Designing Flex and AIR applications
Designing Flex and AIR applicationsDesigning Flex and AIR applications
Designing Flex and AIR applicationsmarcocasario
 
Developing Mash up applications with Adobe AIR
Developing Mash up applications with Adobe AIRDeveloping Mash up applications with Adobe AIR
Developing Mash up applications with Adobe AIRmarcocasario
 
Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008marcocasario
 
Rich Internet Application con Flex, AIR e Java
Rich Internet Application con Flex, AIR e JavaRich Internet Application con Flex, AIR e Java
Rich Internet Application con Flex, AIR e Javamarcocasario
 
Developing Adobe AIR desktop applications
Developing Adobe AIR desktop applicationsDeveloping Adobe AIR desktop applications
Developing Adobe AIR desktop applicationsmarcocasario
 
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3marcocasario
 
Choosing the right Rich Internet Application technology path
Choosing the right Rich Internet Application technology pathChoosing the right Rich Internet Application technology path
Choosing the right Rich Internet Application technology pathmarcocasario
 

Mais de marcocasario (20)

HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...
HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...
HTML5, CSS3 e Javascript per sviluppare Web App per tutti gli schermi - Codem...
 
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...
HTML5 Italy: Back end ecosystems for your applications - Cesare Rocchi + Clau...
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
 
HTML5 cross-platform and device development: web app per tutti gli schermi
HTML5 cross-platform and device development: web app per tutti gli schermiHTML5 cross-platform and device development: web app per tutti gli schermi
HTML5 cross-platform and device development: web app per tutti gli schermi
 
Applicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore RomeoApplicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore Romeo
 
Mobile HTML5 Web Apps - Codemotion 2012
Mobile HTML5 Web Apps - Codemotion 2012Mobile HTML5 Web Apps - Codemotion 2012
Mobile HTML5 Web Apps - Codemotion 2012
 
Enterprise Spring and Flex applications
Enterprise Spring and Flex applicationsEnterprise Spring and Flex applications
Enterprise Spring and Flex applications
 
Local Persistent data with ActionScript 3 and AIR
Local Persistent data with ActionScript 3 and AIRLocal Persistent data with ActionScript 3 and AIR
Local Persistent data with ActionScript 3 and AIR
 
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3
Enterprise Rich Internet Applications con Java, Livecycle DS e Flex 3
 
Adobe TechConnection: Flex Best Practices
Adobe TechConnection: Flex Best PracticesAdobe TechConnection: Flex Best Practices
Adobe TechConnection: Flex Best Practices
 
We make it RIA at Comtaste
We make it RIA at ComtasteWe make it RIA at Comtaste
We make it RIA at Comtaste
 
Flex and AIR User Interface Design Showcases and Examples
Flex and AIR User Interface Design Showcases and ExamplesFlex and AIR User Interface Design Showcases and Examples
Flex and AIR User Interface Design Showcases and Examples
 
Designing Flex and AIR applications
Designing Flex and AIR applicationsDesigning Flex and AIR applications
Designing Flex and AIR applications
 
Developing Mash up applications with Adobe AIR
Developing Mash up applications with Adobe AIRDeveloping Mash up applications with Adobe AIR
Developing Mash up applications with Adobe AIR
 
FlexCamp London
FlexCamp LondonFlexCamp London
FlexCamp London
 
Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008Flex Daily Solutions @ FITC 2008
Flex Daily Solutions @ FITC 2008
 
Rich Internet Application con Flex, AIR e Java
Rich Internet Application con Flex, AIR e JavaRich Internet Application con Flex, AIR e Java
Rich Internet Application con Flex, AIR e Java
 
Developing Adobe AIR desktop applications
Developing Adobe AIR desktop applicationsDeveloping Adobe AIR desktop applications
Developing Adobe AIR desktop applications
 
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3
Developing AJAX pages using the Adobe Spry framework in Dreamweaver CS3
 
Choosing the right Rich Internet Application technology path
Choosing the right Rich Internet Application technology pathChoosing the right Rich Internet Application technology path
Choosing the right Rich Internet Application technology path
 

Último

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Último (20)

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 

Architecting ActionScript 3 applications using PureMVC

  • 2. PureMVC Framework The PureMVC framework has a very narrow goal. That is to help you separate your application’s coding interests into three discrete tiers: M odel, View and Controller. This separation is very important in the building of scalable and maintainable applications. In this implementation of the classic MVC Design metapattern, these three tiers of the application are governed by three Singletons ( class where only one instance may be created) a called simply Model, View and Controller. Together, they are referred to as the ‘Core actors’. A fourth Singleton, the Façade simplifies development by providing a single interface for communication with the Core actors.
  • 4. PureMVC Architecture M odel & Proxies The Model simply caches named references to Proxies. Proxy code manipulates the data model, communicating with remote services if need be to persist or retrieve it. This results in portable Model tier code. View & M ediators The View primarily caches named references to Mediators. Mediator code stewards View Components, adding event listeners, sending and receiving notifications to and from the rest of the system on their behalf and directly manipulating their state. This separates the View definition from the logic that controls it.
  • 5. PureMVC Architecture Controller & Commands The Controller maintains named mappings to Command classes, which are stateless, and only created when needed. Commands may retrieve and interact with Proxies, send Notifications, execute other Commands, and are often used to orchestrate complex or system- wide activities such as application startup and shutdown. They are the home of your application’s Business Logic.
  • 6. PureMVC Architecture Façade & Core The Façade, another Singleton, initializes the Core actors (Model, View and Controller) and provides a single place to , access all of their public methods. By extending the Façade, your application gets all the benefits of Core actors without having to import and work with them directly. You will implement a concrete Façade for your application only once and it is simply done. Proxies, Mediators and Commands may then use your application’s concrete Façade in order to access and communicate with each other.
  • 7. PureMVC Architecture Observers & Notifications PureMVC applications may run in environments without access to Flash’s Event and EventDispatcher classes, so the framework implement s an Obser ver not ificat ion scheme for communication between the Core MVC actors and other parts of the system in a loosely- coupled way. You need not be concerned about the details of the PureMVC Observer/ Notification implementation; it is internal to the framework. You will use a simple method to send Notifications from Proxies, Mediators, Commands and the Façade itself that doesn’t even require you to create a Notification instance.
  • 8. PureMVC Architecture Notifications can be used to trigger command execution. Commands are mapped to Notification names in your concrete Façade, and are automatically executed by the Controller when their mapped Notifications are sent. Commands typically orchestrate complex interaction between the interests of the View and Model while knowing as little about each as possible.
  • 9. PureMVC Architecture Mediators Send, Declare Interest In and Receive Notifications When they are registered with the View, Mediators are interrogated as to their Notification interests by having their listNotifications method called, and they must return an array of Notification names they are interested in. Later, when a Notification by the same name is sent by any actor in the system, interested Mediators will be notified by having their handleNotification method called and being passed a reference to the Notification.
  • 10. PureMVC Architecture Proxies Send, But Do Not Receive Notifications Proxies may send Notifications for various reasons, such as a remote service Proxy alerting the system that it has received a result or a Proxy whose data has been updated sending a change Notification.
  • 11. ApplicationFacade //A concrete Facade for MyApp public class ApplicationFacade extends Façade implements IFacade { // Define Notification name constants public static const STARTUP:String = quot;startupquot;; public static const LOGIN:String = quot;loginquot;; // Singleton ApplicationFacade Factory Method public static function getInstance() : ApplicationFacade { if ( instance == null ) instance = new ApplicationFacade( ); return instance as ApplicationFacade; } // Register Commands with the Controller override protected function initializeController( ) : void { super.initializeController(); registerCommand( STARTUP, StartupCommand ); registerCommand( LOGIN, LoginCommand ); registerCommand( LoginProxy.LOGIN_SUCCESS, GetPrefsCommand ); } // Startup the PureMVC apparatus, passing in a reference to the app public public startup( app:MyApp ) : void { sendNotification( STARTUP, app ); } }
  • 12. Main Application <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <mx:Application xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; creationComplete=quot;façade.startup(this)”> <mx:Script> <![CDATA[ // Get the ApplicationFacade import com.me.myapp.ApplicationFacade; private var facade:ApplicationFacade = ApplicationFacade.getInstance(); ]]> </mx:Script> <!—Rest of display hierarchy defined here --> </mx:Application>
  • 13. Startup Command This is a MacroCommand that adds two sub-commands, which are executed in FIFO order when the MacroCommand is executed. package com.me.myapp.controller { import org.puremvc.as3.interfaces.*; import org.puremvc.as3.patterns.command.*; import com.me.myapp.controller.*; // A MacroCommand executed when the application starts. public class StartupCommand extends MacroCommand { // Initialize the MacroCommand by adding its subcommands. override protected function initializeMacroCommand() : void { addSubCommand( ModelPrepCommand ); addSubCommand( ViewPrepCommand ); } } }
  • 14. ModelPrepCommand Preparing the Model is usually a simple matter of creating and registering all the Proxies the system will need at startup. package com.me.myapp.controller { import org.puremvc.as3.interfaces.*; import org.puremvc.as3.patterns.observer.*; import org.puremvc.as3.patterns.command.*; import com.me.myapp.*; import com.me.myapp.model.*; // Create and register Proxies with the Model. public class ModelPrepCommand extends SimpleCommand { // Called by the MacroCommand override public function execute( note : INotification ) : void { facade.registerProxy( new SearchProxy() ); facade.registerProxy( new PrefsProxy() ); facade.registerProxy( new UsersProxy() ); } } }
  • 15. ViewPrepCommand This is a SimpleCommand that prepares the View for use. It is the last of the previous MacroCommand’s subcommands, and so, is executed last. package com.me.myapp.controller { import org.puremvc.as3.interfaces.*; import org.puremvc.as3.patterns.observer.*; import org.puremvc.as3.patterns.command.*; import com.me.myapp.*; import com.me.myapp.view.*; // Create and register Mediators with the View. public class ViewPrepCommand extends SimpleCommand { override public function execute( note : INotification ) : void { var app:MyApp = note.getBody() as MyApp; facade.registerMediator( new ApplicationMediator( app ) ); } } }
  • 16. Sample Proxy // A proxy to log the user in public class LoginProxy extends Proxy implements IProxy { private var loginService: RemoteObject; public function LoginProxy () { super( NAME, new LoginVO ( ) ); loginService = new RemoteObject(); loginService.source = quot;LoginServicequot;; logi nService.destination = quot;GenericDestinationquot;; loginService.addEventListener( FaultEvent.FAULT, onFault ); loginService.login.addEventListener( ResultEvent.RESULT, onResult ); } // Cast data object with implicit getter public function get loginVO( ) : LoginVO { return data as LoginVO; } // The user is logged in if the login VO contains an auth token public function get loggedIn():Boolean { return ( authToken != null ); } // Subsequent calls to services after login must include the auth token public function get authToken():String { return loginVO.authToken; }
  • 17. Sample ViewMediator public class LoginPanelMediator extends Mediator implements IMediator { public static const NAME:String = 'LoginPanelMediator'; public function LoginPanelMediator( viewComponent:LoginPanel ) { super( NAME, viewComponent ); LoginPanel.addEventListener( LoginPanel.TRY_LOGIN, onTryLogin ); } // List Notification Interests override public function listNotificationInterests( ) : Array { return [ LoginProxy.LOGIN_FAILED, LoginProxy.LOGIN_SUCCESS ]; } // Handle Notifications override public function handleNotification( note:INotification ):void { switch ( note.getName() ) { case LoginProxy.LOGIN_FAILED: LoginPanel.loginVO = new LoginVO( ); loginPanel.loginStatus = LoginPanel.NOT_LOGGED_IN; Break; ...