O'Reilly logo

C++ Reactive Programming by Peter Abraham, Praseed Pai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A tale of two operators – flat versus concat map

A source of confusion among developers is often centered around the flat map and concat map operators. Their differences are really subtle and we will cover them in this section. Let's take a look at the flat map operator andn 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required