Converting an arbitrary Lambda to a custom Rx operator

In the previous section, we learned that it is possible to use the lift<t> operator to implement custom operators that can be part of the operator chaining infrastructure of the RxCpp library. The workings of lift<T> are a bit complicated and we will write an Adapter class to convert an arbitrary Lambda that takes a parameter (of the basic types) to a form where the lift<T> operator can be applied.

The adapter code will help us to make calls such as this:

observable<T>::lift<T>( liftaction( lambda<T> ) )

Let's write an Adapter class implementation and a generic function wrapper on top of it to be consumed in a program:

//----------- operatorLiftSecond.cpp #include "rxcpp/rx.hpp" #include ...

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.