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 <AppFacade>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单例创建后设置秘钥
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。