June 2018
Intermediate to advanced
348 pages
8h 45m
English
We can concatenate two Streams to form a new Stream and this can be handy in some cases. Let's see how this works by writing a simple program:
//------------- Concactatenate.cpp
#include "rxcpp/rx.hpp"
#include "rxcpp/rx-test.hpp"
int main() {
auto values = rxcpp::observable<>::range(1);
auto s1 = values.take(3).map([](int prime) { return 2*prime;);});
auto s2 = values.take(3).map([](int prime) { return prime*prime);});
s1.concat(s2).subscribe(rxcpp::util::apply_to(
[]( int p) { printf(" %dn", p);}));
}
The concat Operator append the contents of constituent Observable Streams one after another by preserving the order. In the preceding code,after creating an Observable (values), we did create two additional ...