June 2018
Intermediate to advanced
348 pages
8h 45m
English
A Subject is an entity that is both an Observer and an Observable. It helps to relay notifications from one Observable (typically) to a set of Observers. We can implement sophisticated techniques such as the caching and buffering of data using a Subject. We can also use a Subject to transform a hot Observable into a cold Observable. There are four variants of subjects implemented in RxCpp library. They are as follows:
Let's write a simple program that will demonstrate the work of a Subject. The code listing will demonstrate how we can push data to a Subject and retrieve them using the Observer side of the Subject.
//------- SimpleSubject.cpp #include <rxcpp/rx.hpp> ...