观察者模式是相反的? [英] What is the opposite of the observer pattern?
问题描述
p>仍然可以使用Observer模式:只有与许多监视对象的观察者具有相同的对象注册。您可能希望通知事件接收某种观察对象标识符(this指针,唯一的ID号等),以便观察者对象可以选择适合报告事件的对象的操作。 / p>
As I understand it, the observer pattern allows for multiple observers to monitor a single subject. Is there a pattern for the opposite scenario? Is there a pattern for a single observer that monitors several subjects and responds when any one of them raises, say, a Notify event?
The Observer pattern can still be used: just have the same object register as an observer to many monitored objects. You'll probably want the "Notify" event to receive some kind of observed-object identifier (the "this" pointer, a unique id number etc) so that the observer object can choose an action appropriate to the object reporting the event.
这篇关于观察者模式是相反的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!