13#include <rpp/defs.hpp>
14#include <rpp/observers/constraints.hpp>
15#include <rpp/observers/specific_observer.hpp>
16#include <rpp/subscribers/fwd.hpp>
17#include <rpp/subscribers/details/subscriber_base.hpp>
18#include <rpp/subscriptions/composite_subscription.hpp>
19#include <rpp/utils/function_traits.hpp>
28template<constra
int::decayed_type Type, constra
int::decayed_observer Observer>
33 template<
typename ...Types>
36 , m_observer{ std::forward<Types>(vals)... } {}
38 template<
typename ...Types>
40 : subscriber_base{ std::move(sub)}
41 , m_observer{ std::forward<Types>(vals)... } {}
43 const Observer& get_observer()
const
48 void on_next(
const Type& val)
const
53 void on_next(Type&& val)
const
55 on_next_impl(std::move(val));
58 void on_error(
const std::exception_ptr& err)
const
60 do_if_subscribed_and_unsubscribe([&err,
this] { m_observer.on_error(err); });
63 void on_completed()
const
65 do_if_subscribed_and_unsubscribe([
this] { m_observer.on_completed(); });
72 void on_next_impl(
auto&& val)
const
79 m_observer.on_next(std::forward<
decltype(val)>(val));
83 on_error(std::current_exception());
87 RPP_NO_UNIQUE_ADDRESS Observer m_observer{};
90template<constra
int::observer TObs>
93template<constra
int::observer TObs>
96template<
typename OnNext,
98 typename Type = std::decay_t<utils::function_argument_t<OnNext>>>
101template<
typename OnNext,
103 typename Type = std::decay_t<utils::function_argument_t<OnNext>>>
110template<
typename Type,
typename ...Args>
111auto make_specific_subscriber(Args&& ...args) ->
specific_subscriber<Type, details::deduce_specific_observer_type_t<Type, Args...>>
113 return {std::forward<Args>(args)...};
116template<
typename Type,
typename ...Args>
117auto make_specific_subscriber(composite_subscription sub, Args&& ...args) -> specific_subscriber<Type, details::deduce_specific_observer_type_t<Type, Args...>>
119 return {std::move(sub), std::forward<Args>(args)...};
122template<
typename Type, constra
int::observer_of_type<Type> TObs,
typename ...Args>
123auto make_specific_subscriber(composite_subscription sub, Args&& ...args) -> specific_subscriber<Type, TObs>
125 return {std::move(sub), std::forward<Args>(args)...};
rpp::subscription_base with ability to add some dependent subscriptions as a part of this one: in cas...
Definition: composite_subscription.hpp:30
base implementation of subscriber with possibility to obtain observer's callbacks,...
Definition: subscriber_base.hpp:23
subscriber which uses dynamic_observer<T> to hide original callbacks
Definition: dynamic_subscriber.hpp:24
specific version of subscriber which stores type of observer used inside to prevent extra allocations
Definition: specific_subscriber.hpp:31