Thanks for this. Another analogy I thought of while watching was a person receiving a text or email. Rather than constantly checking your messages for a reply to a text, your phone has this neat functionality where is vibrates or makes a noise when the you receive a text.
You can have 2 implementations. One is where a subject broadcasts ( or "pushes" ) to all its observers its changed state, the other is when observers ask ( "pull") from the subjects its state when needed. Where one compromises reuse, the other is less efficient ( more calls ). In our case, the news guy(subject) can be asked by the news agencies(the observers) about his availability(state), so they can send him the requirements for the next news. On the other hand, the news guy(subject) can have multiple news agencies(observers) registered in a list, and if he finds some news, he will broadcast ( send ) to the agencies those news ( state ). This pattern can also be extended even more, where you have multiple news guys, communicating back and forth with multiple news agencies and providing different types of news, depending on different types of availability from the agencies.
The most realistic example from a few explanations I've seen. But, you've never declared a 'listener' in your example. In this case the listener could be an ui form Label that implements an IObserver interface. IObserver Interface could have a single method Notify(string text). Then Notify method will take changes from the Text box and displays modified value of the text box. Like this: //Declarations interface IObserver { Notify(string text); } class Label : IObserver(), FormLabel { Notify(string text) { var IntValue = (int)text; Label.value.text = intValue*0.05; //displays 5% of text box value. } //FormLabel code here. } class TextBox : IObservable : FormTextBox { void Add(IObserver observer) { myObservers.Add (observer); } void Remove(IObserver observer) { myObservers.Remove(observer); } void OnChange() { ForEach(IObserver obsv in myObservers) { obsv.Notify(myNewText); } } } //initialization: TextBox txtBox1 = new TextBox(); textBox1.Add(label1); // now changes in the text box will trigger the notifications in observers. in this case a Label.
this sounds familiar. seems like android uses observer pattern. in android we register ActionListener with a button. I guess this makes the ActionListeners "news bureaus". when event onClick takes place, button notifies the actionListener by calling it back using their callback function. this makes button "reporter".