I got a class Container
which holds a list of variables of type DataStruct
. Each DataStruct
has a name and a value. It is possible to add DataStruct
objects to that list.
Other objects want to subscribe to a DataStruct
to get notified when its value changes. Obviously one could use the observer pattern here and notify each observer whenever a DataStruct
's value is changed. However, every observer would always be notified about all value changes, even if he is only interested in a single kind of DataStruct
(identified by its name).
How would you solve this problem? Filter inside the Observer and live with the fact that it gets notified about every value change?
Aucun commentaire:
Enregistrer un commentaire