I program with RX in C#, and now I wish to program with rxcpp in c++.
I am trying to do the simplest thing, define a class member variable of observable<int>
.
The problem is that observable
is defined as:
template<class T, class SourceOperator>
class observable
What is SourceOperator
?
How do I define a simple observable<int>
?
When looking in the code, at rx-observable.hpp(line 101):
template<class T, class Source>
observable<T> make_observable_dynamic(Source&& s) {
return observable<T>(dynamic_observable<T>(std::forward<Source>(s)));
}
I find observale<T>
as a return type, but couldn't find its definition.
It so weird. I honestly though I am quite proficient in c++11\14 & Metaprogramming... apparently the rabbit hole can get much deeper :-(
Update 1:
observale<T>
has been found :-)
its in rx-predef.hpp:
template<class T = void,
class SourceObservable = typename std::conditional<std::is_same<T,void>::value,
void,
dynamic_observable<T>>::type>
class observable;
o.k. my current guess is that dynamic_observable
means that a 'regular' observable<T>
is a dynamic, type-ereased stream of T.
It's logical, as you can only sotre type-erased stream as a variable with an explicit type.
What brings me to my next guess, that the syntax of template<class T, class SourceOperator> class observable
enable the creation of observable type combined from other observable in the 'decorator' pattern (compile time decoration). something like exemplified here