What is the opposite of the observer pattern?

后端 未结 5 1662
一向
一向 2020-12-05 07:26

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

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 08:19

    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.

提交回复
热议问题