An observable collection implements the famous "Observer" design pattern. It is one of the design patterns that are listed in the famous book of the GOF.
The basic idea is as follows - if several objects has some dependency on the same object, such that when some interesting things happen inside that object, all those dependent objects should be notified about the event immediately, then this pattern is used. Here we call the dependent objects as the "Observer", and the objects onto which they all are depending as "Subject". When some event happens inside the subject, it is the responsibility of the subject to notify all the observers about this event. To facilitate this sort of message passing, all the observers has to subscribe to the subject when they are created. Details can be found here.
发布评论
评论(1)
可观察集合实现了著名的“观察者”设计模式。它是GOF名著中列出的设计模式之一。
基本思想如下 - 如果多个对象对同一个对象有一定的依赖关系,这样当该对象内部发生一些有趣的事情时,所有这些依赖对象都应该立即收到有关该事件的通知,然后使用此模式。这里我们将依赖对象称为“观察者”,将它们所依赖的对象称为“主体”。当主体内部发生某些事件时,主体有责任将该事件通知给所有观察者。为了促进这种消息传递,所有观察者都必须在创建主题时订阅该主题。详细信息可以在此处。
An observable collection implements the famous "Observer" design pattern. It is one of the design patterns that are listed in the famous book of the GOF.
The basic idea is as follows - if several objects has some dependency on the same object, such that when some interesting things happen inside that object, all those dependent objects should be notified about the event immediately, then this pattern is used. Here we call the dependent objects as the "Observer", and the objects onto which they all are depending as "Subject". When some event happens inside the subject, it is the responsibility of the subject to notify all the observers about this event. To facilitate this sort of message passing, all the observers has to subscribe to the subject when they are created. Details can be found here.