October 2018
Intermediate to advanced
556 pages
15h 18m
English
In this chapter, we have talked a lot about the Observer pattern, which gives us a clearly separated view of the Producer event and Consumer event. Let's have a recap of the interfaces defined by that pattern, as shown in the following code:
public interface Observer<T> { void notify(T event);}public interface Subject<T> { void registerObserver(Observer<T> observer); void unregisterObserver(Observer<T> observer); void notifyObservers(T event);}
As we saw previously, this approach is charming for infinite streams of data, but it would be great to have the ability to signal the end of the data stream. Also, we do not want the Producer to generate events before the appearance of consumers. In the ...