TypeScript的PureMVC框架之Facade类;
Facade类
facade类是pureMVC框架的单例类,Facade提供了与核心层通信的唯一接口
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、网站空间、营销软件、网站建设、新乡县网站维护、网站推广。
以下是AppFacade单例类 继承自puremvc.Facade
static getInstance(facadeID:string = "AppFacade"):AppFacade
{
if(!puremvc.Facade.instanceMap[facadeID])
{
puremvc.Facade.instanceMap
puremvc.Facade.instanceMap["AppFacade"] = new AppFacade("AppFacade");
}
return puremvc.Facade.instanceMap["AppFacade"];
}
此类调用puremvc.Facade中的接口函数,通用方法如下: AppFacade.getInstance().sendNotification()
Facade类成员:
public model: IModel; ---------------------------------------------------------------------------------------------Model单例
public view: IView;--------------------------------------------------------------------------------------------------View单例
public controller: IController;-------------------------------------------------------------------------------------Controller单例
public multitonKey: string;----------------------------------------------------------------------------------------Facade单例创建后设置秘钥
constructor (key:string);-------------------------------------------------------------------------------------------构造函数
Facade类的成员函数:
public initializeFacade(): void;-----------------------------------------------------------------------------------初始化Facade单例
public initializeModel(): void;-------------------------------------------------------------------------------------Facade完成后初始化Model
public initializeController(): void;--------------------------------------------------------------------------------Facade完成后初始化Controller
public initializeView(): void;---------------------------------------------------------------------------------------Facade完成后初始化View
public registerCommand(notificationName: string, commandCla***ef: Function): void;---------注册命令,并设置一个命令的名字
public removeCommand(notificationName: string): void;-------------------------------------------------移除命令
public hasCommand(notificationName: string): boolean;-------------------------------------------------检测通知名是否注册命令
public registerProxy(proxy: IProxy): void;---------------------------------------------------------------------通过模型名注册代理
public retrieveProxy(proxyName: string): IProxy;-----------------------------------------------------------检索代理
public removeProxy(proxyName: string): IProxy;-----------------------------------------------------------移除代理
public hasProxy(proxyName: string): boolean;--------------------------------------------------------------检测代理是否注册
public registerMediator(mediator: IMediator): void;---------------------------------------------------------注册Mediator
public retrieveMediator(mediatorName: string): IMediator;-----------------------------------------------检索Mediator
public removeMediator(mediatorName: string): IMediator;-----------------------------------------------移除mediator
public hasMediator(mediatorName: string): boolean;------------------------------------------------------检测Mediator
public notifyObservers(notification: INotification):void;-----------------------------------------------------此方法主要用于向后兼容性,并允许您使用Facade来发送自定义通知类
public sendNotification(name: string, body?: any, type?: string):void;----------------------------------创建发送通知,实现通信
public initializeNotifier(key: string): void;-----------------------------------------------------------------------Facade单例创建后设置秘钥
当前题目:TypeScript的PureMVC框架之Facade类;
转载源于:http://scyanting.com/article/jhccgh.html