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

We can convert a cold Observable into a hot Observable by invoking the Observable's publish method. The consequence of converting a cold Observable to a hot Observable will be the fact that data can be missed by later subscriptions. A hot Observable emits data whether there is a subscription or not. The following program demonstrates the behavior:

//---------- HotObservable.cpp#include <rxcpp/rx.hpp> #include <memory> int main(int argc, char *argv[]) { auto eventloop = rxcpp::observe_on_event_loop(); //----- Create a Cold Observable //----- Convert Cold Observable to Hot Observable //----- using .Publish(); auto values = rxcpp::observable<>::interval( std::chrono::seconds(2)).take(2).publish(); //----- Subscribe Twice values. ...
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