zoukankan      html  css  js  c++  java
  • 初始化程序PureMVC学习(二)

    本文纯属个人见解,是对前面学习的总结,如有描述不正确的地方还请高手指正~

        Command与Mediator和Proxy交互,应免避Mediator与Proxy直接交互。看上面一个用于程序"启动"的Command:

    package com.wf.controller
    {
    	import org.puremvc.as3.core.Model;
    	import org.puremvc.as3.patterns.command.MacroCommand;
    
    	/**
    	 * 程序开始时行执的MacroCommand
    	 */ 
    	public class StartupCommand extends MacroCommand
    	{
    		/**
    		 * 添加子Command初始化MacroCommand
    		 */ 
    		override protected function initializeMacroCommand():void
    		{
    			addSubCommand(ModelPrepCommmand);
    			addSubCommand(ViewPrepCommand);
    		}
    	}
    }

        这是一个添加了两个子Command的MacroCommand.行执时,两个子命令会按照FIFO的次序被行执。

        一般,开启(startup)主要有两个进程:Model初始化与View初始化。

        每日一道理
    如果人类不好好保护我们这个赖以生存的地球,终有一天,风沙的肆虐与垃圾的堆积会吞没我们美丽的家园。我向全世界的人们呼吁:让我们从现在开始,从我做起,手挽手,肩并肩共同保护建设我们的家园吧!
    package com.wf.controller
    {
    	import org.puremvc.as3.interfaces.INotification;
    	import org.puremvc.as3.patterns.command.SimpleCommand;
    
    	//创立Proxy象对,并注册
    	public class ModelPrepCommand extends SimpleCommand
    	{
    		//由MacroConmmand调用
    		override public function execute(notification:INotification):void
    		{
    			facade.registerProxy(new SearchProxy());
    			facade.registerProxy(new PrefsProxy());
    			facade.registerProxy(new UserProxy());
    		}
    	}
    }

        Command并没有作操或初始化任何的Model数据.Proxy的责职才是得取、创立 和初始化数据象对。

    package com.wf.controller
    {
    	import mx.core.Application;
    	
    	import org.puremvc.as3.interfaces.INotification;
    	import org.puremvc.as3.patterns.command.SimpleCommand;
    
    	//创立Mediator,并把他们注册到View
    	public class ViewPrepCommand extends SimpleCommand
    	{
    		override public function execute(notification:INotification):void
    		{
    			var app:PureMvcStudy = notification.getBody() as PureMvcStudy;
    			facade.registerMediator(new ApplicationMediator(app));
    		}
    	}
    }

    文章结束给大家分享下程序员的一些笑话语录: 联想——对内高价,补贴对外倾销的伟大“民族”企业。

  • 相关阅读:
    初识nginx
    Keepalived 配置实例
    ssh学习小记
    代码开发、测试及发布
    需求改进&系统设计
    软件设计原则、设计模式学习+部分实现
    自我介绍+课程 6 问
    python函数嵌套出现报错UnboundLocalError原理的猜测(有解决办法,但是对于报错原理不确定)
    python tkinter 问题(多个Listbox选取显示问题,虚拟事件的特点为何虚拟,listbox.nearest函数与虚拟事件绑定返回值错误,StringVar类参数调用时单向性,线程无响应)
    python tkinter pack布局遇到的错误和问题总结(无图)
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3057438.html
Copyright © 2011-2022 走看看