Skip to Content
C++ Reactive Programming
book

C++ Reactive Programming

by Praseed Pai, Peter Abraham
June 2018
Intermediate to advanced
348 pages
8h 45m
English
Packt Publishing
Content preview from C++ Reactive Programming

Subjects

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:

  • SimpleSubject
  • BehaviorSubject
  • ReplaySubject
  • SynchronizeSubject

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> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in C++

Functional Programming in C++

Ivan Cukic

Publisher Resources

ISBN: 9781788629775Supplemental Content