Having this class diagram, let's say inside the Notify() method we call the Update() method of each Observer attached to the Subject. How would this work in a case where the subjects are on one device and the observer are on another?
Let's say the subjects represent an arduino board with a couple of sensors, and the observers are on a website or an app where it will display the variables reading from the sensor. Once the readings of a sensor change we want to notify all of the observers attached to the subject but we wouldn't just be able to just call observer.Update() since the actual instance of that object wouldn't be in the same device.
In that scenario how would you actually implement the observer pattern? and what would the code look like in some of the methods like Notify() and Update(), and how would it work with some technologies like MQTT or WebSockets?
Aucun commentaire:
Enregistrer un commentaire