June 2018
Intermediate to advanced
348 pages
8h 45m
English
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()). ...