Define a one-to-many dependency between objects, so that when one object (Observable) changes state, all its dependents (Observer) are notified and updated automatically.
A newspaper publisher goes into business and begins publishing newspaper. You subscribe to a particular publisher, and every time there's a new edition it gets delivered to you. As long as you remain a subscriber, you get new newspaper. Then you unsubscribe when you don't want papers anymore, and the stop being delivered. While the publisher remains in business, people, hotels, airlines and other businesses constantly subscribe and unsubscribe to the newspaper.
The attached example uses a Text Display for illustration:
We have a text message object, the text message will notify all text displays when there is a new text updated. All text displays can register or unregister themselves.
First, we design the interface of Observable and Observer.
We use an array of Observers as the private data of Observable. Because LabVIEW is a data flow language, the wire should be passed back when the data of the wire has been updated. In this application, Observers can register and unregister themselves. To avoid passing back wire after Observers register or unregister, we use DVR (Data Value Reference) to enclose the private data of Observable.
Then we create a Text Message class that inherit from Observable.
In this example, we want to display text normally and reversed, so we create two Observers.
Normal Text and Reserve Text will override Observer's methods and use Observable as theirs private data, so that they can register or unregister themselves.