PureMVC使用小结

总结PureMVC的工作流程:
主应用程序要先实例化一个Facade,也就是启动了Facade,然后再由它去实例化Mediator,Proxy和Command,Proxy更新Model中的数据后发送消息,它不管谁去接收,这就解耦合了,Mediator可以发送消息也可以接收消息,它是负责更新View,Command是处理消息,它在启动的时候就会注册相应的Proxy或Mediator,处理Mediator发送过来的通知并调用Proxy中的方法处理。
Mediator是直接和View层相连,控制component,包括单击,拖动数据改变等事件,然后会发送消息给Command,它会实例化一个Notification对应的Command对象,将自身作为参数传递给execute()方法,它会去转发给Proxy,Proxy处理过后发送消息,当Mediator接收的后会控制View显示。
[color=darkred]一个消息是可以被多个Mediator接收的,只要Mediator里添加了对Notification的接收就可以,至于接收的顺序是看它注册的先后次序[/color],如:
下面两个同样都添加了对LoginProxy.LOGIN_SUCCESS的接收
public class ViewCommand extends SimpleCommand implements ICommand
{
override public function execute(notification:INotification):void{
//主应用启动时,注册Mediator
var app:PureMVCLogin = notification.getBody() as PureMVCLogin;
facade.registerMediator(new ApplicationMediator(app)); //它就会先执行
facade.registerMediator(new LoginMediator(app)); //它会后执行
}
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值