The examples I've seen on the internet only give notifyObservers()
method to the Observable object. What if I want to also pass some data to the observers, so that they know if they should react to it or not? Does the observer pattern allow passing the data like maybe:
notifyObservers(Event e)
.
Or maybe the observers themselves should pull the change? Like maybe: notifyObservers() -> call observer.update()
and then each observer decides if the new data is relevant for them, observable.getData()
. However with this approach, it is unclear to me, how to get only the data that has changes, if it's at all needed.
Aucun commentaire:
Enregistrer un commentaire