Type-full observable (or typed) that has the notion of Type and upstream observables for C++ compiler. e.g. observable<int, map<bool, ...recursive...>> is different from observable<int, filter<int, ...>>. More...
#include <specific_observable.hpp>
Public Member Functions | |
specific_observable (OnSubscribeFn &&on_subscribe) | |
specific_observable (const OnSubscribeFn &on_subscribe) | |
specific_observable (const specific_observable &other)=default | |
specific_observable (specific_observable &&other) noexcept=default | |
specific_observable & | operator= (const specific_observable &other)=default |
specific_observable & | operator= (specific_observable &&other) noexcept=default |
template<typename... Args> requires details::is_header_included<details::dynamic_observable_tag, Args...> | |
auto | as_dynamic () const & |
Converts rpp::specific_observable to rpp::dynamic_observable via type-erasure mechanism. | |
template<typename... Args> requires details::is_header_included<details::dynamic_observable_tag, Args...> | |
auto | as_dynamic () && |
Public Member Functions inherited from rpp::interface_observable< Type, specific_observable< Type, OnSubscribeFn > > | |
auto | op (OperatorFn &&fn) const & |
The apply function to observable which returns observable of another type. | |
auto | op (OperatorFn &&fn) && |
auto | as_blocking () const & |
Converts existing observable to rpp::blocking_observable which has another interface and abilities. | |
auto | as_blocking () && |
Friends | |
struct | details::member_overload< Type, specific_observable< Type, OnSubscribeFn >, details::subscribe_tag > |
Type-full observable (or typed) that has the notion of Type and upstream observables for C++ compiler. e.g. observable<int, map<bool, ...recursive...>> is different from observable<int, filter<int, ...>>.
This is a C++ technique about de-virtualization. To achieve polymorphic behavior, we could either go for function virtualization or function overload. However, virtualization is more expensive than function overload in both compile time and runtime. Therefore, we go for function overload. Actually, we use more advanced functor paradigm for better performance. As a result it has better performance comparing to rpp::dynamic_observable. Use it if possible. But it has worse usability due to OnSubscribeFn template parameter.
Type | is the value type. Observable of type means this source could emit a sequence of items of that "Type". |
OnSubscribeFn | is the on_subscribe functor that is called when a subscriber subscribes to this observable. specific_observable stores OnSubscribeFn as member variable, so, it is stored on stack (instead of allocating it on heap). |
This is a C++ technique about de-virtualization. To achieve polymorphic behavior, we could either go for function virtualization or function overload. However, virtualization is more expensive than function overload in both compile time and runtime. Therefore, we go for function overload. Actually, we use more advanced functor paradigm for better performance. As a result it has better performance comparing to rpp::dynamic_observable. Use it if possible. But it has worse usability due to OnSubscribeFn template parameter.
Type | is the value type. Observable of type means this source could emit a sequence of items of that "Type". |
OnSubscribeFn | is the on_subscribe functor that is called when a subscriber subscribes to this observable. specific_observable stores OnSubscribeFn as member variable, so, it is stored on stack (instead of allocating it on heap). |