| registerObserver( interests, observer ); } } mediator.onRegister(); } 这里仍然是创建observer,保存mediator.handleNotification和mediator对象 那么sendNotification以后,通过mediator的listNotificationInterests数组中的名字,来索引到对应的Observer, public function notifyObserver( notification:INotification ):void { this.getNotifyMethod().apply(this.getNotifyContext(),[notification]); } 这里本质调用了mediator.handleNotification,并传入参数notification对象。 综上所述,sendNotification实际上是通过名字来索引到对应的Observer,由Observer调用注册的Controller对象的executeCommand方法或者Mediator对象的handleNotification方法。 |
相关文章: