Writing custom operators that can be chained
One of the key benefits of built-in operators provided by the RxCpp library is the possibility to chain operators using fluent interfaces. This significantly improves code readability. The custom operators that we've created so far can be composed together, but cannot be chained together in the way the standard operator can be chained. In this section, we will implement operators that can be chained by using the following methods:
- Using the
lift<T>
meta operator - Writing a new operator by adding code to the RxCpp library
Using the lift<t> operator to write a custom operator
The RxCpp library has an operator as part of the observable<T>
implementation, called lift
(lift<t>
). In fact, it can be called a meta-operator as it has the capability to convert a unary
function or functor that takes an ordinary variable (int
, float
, double
, struct
, and so on) to be compatible for processing observable<T>
Streams. The RxCpp implementation...