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单例创建后设置秘钥

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:TypeScript的PureMVC框架之Facade类;-创新互联
网站路径:http://azwzsj.com/article/cspjdj.html