全部博文(177)
分类:
2010-01-12 15:02:30
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
My understanding is: Observer pattern is a way to notify a series of objects (observers) that something happened in subject object. The subject object "generates" the event and observer objects "receive" it. For example, when mouse click is captured, OS dispatches the event to the window, which in turn calls the event handler of all registered observers. Picture below illustrates the class diagram of this pattern:
|
|