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