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

Hot Observables and the replay mechanism

A hot Observable emits data, whether there is a Subscriber available or not. This can be an issue in scenarios where we expect, subscribers to receive data consistently. There is a mechanism within reactive programming to cache data so that later subscribers can be notified of the data available with an Observable. We can use the .replay() method to create such an Observable. Let's write a program that will demonstrate the replay mechanism, which is useful when writing programs involving hot Observables:

//---------- ReplayAll.cpp #include <rxcpp/rx.hpp> #include <memory> int main(int argc, char *argv[]) { auto values = rxcpp::observable<>::interval( std::chrono::milliseconds(50), rxcpp::observe_on_new_thread()). ...
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