A tale of two Operators – flatmap versus concatmap

A source of confusion among developers is often centered around the flatmap and concatmap  Operators. Their differences are really important and we will cover them in this section. Let's take a look at the flatmap  operator and how it works:

//----------- Flatmap.cpp #include "rxcpp/rx.hpp" #include "rxcpp/rx-test.hpp" #include <ioStream> namespace rxu=rxcpp::util; #include <array> int main() { std::array< std::string,4 > a={{"Praseed", "Peter", "Sanjay","Raju"}}; //---------- Apply Flatmap on the array of names //---------- Flatmap returns an Observable<T> ( map returns T ) //---------- The First lamda creates a new Observable<T> //---------- The Second Lambda manipulates primary Observable ...

Get C++ Reactive Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.