June 2018
Intermediate to advanced
348 pages
8h 45m
English
Let's write a simple program to implement a custom operator by combining other operators, where we filter stream of numbers for odd numbers, transform numbers into its square, and take only first three elements from the stream:
//------ CustomOperator1.cpp #include "rxcpp/rx.hpp" namespace rx { using namespace rxcpp; using namespace rxcpp::operators; using namespace rxcpp::sources; using namespace rxcpp::util; } //------ operator to filter odd number, find square & take first three items std::function<rx::observable<int>(rx::observable<int>)> getOddNumSquare() { return [](rx::observable<int> item) { return item. filter([](int v){ return v%2; }). map([](const int v) { return v*v; }). take(3). //------ ...