Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the opposite of the observer pattern?

Tags:

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?

like image 695
blueshift Avatar asked Feb 10 '11 02:02

blueshift


1 Answers

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.

like image 66
Tony Delroy Avatar answered Sep 19 '22 05:09

Tony Delroy