June 2018
Intermediate to advanced
348 pages
8h 45m
English
The RxCpp library is single-threaded by default, and RxCpp will schedule execution in the thread where we called the subscriber method. There are some operators that take a Scheduler as a parameter, where execution can happen in the thread managed by the Scheduler. Let's write a program to implement a custom operator to work with a Scheduler parameter:
//----------- CustomOperatorScheduler.cpp #include "rxcpp/rx.hpp" template <typename Duration> auto generateObservable(Duration durarion) { //--------- start and the period auto start = rxcpp::identity_current_thread().now(); auto period = durarion; //--------- Observable upto 3 items return rxcpp::observable<>::interval(start, period).take(3); ...