12#include <rpp/defs.hpp>
13#include <rpp/disposables/composite_disposable.hpp>
14#include <rpp/observers/observer.hpp>
15#include <rpp/utils/function_traits.hpp>
17namespace rpp::details::observers
19 template<rpp::constraint::decayed_type Type,
20 std::invocable<Type> OnNext,
21 std::invocable<const std::exception_ptr&> OnError,
22 std::invocable<> OnCompleted>
23 struct lambda_strategy
25 static constexpr auto preferred_disposables_mode = rpp::details::observers::disposables_mode::Auto;
27 template<rpp::constra
int::decayed_same_as<OnNext> TOnNext, rpp::constra
int::decayed_same_as<OnError> TOnError, rpp::constra
int::decayed_same_as<OnCompleted> TOnCompleted>
28 explicit lambda_strategy(TOnNext&& on_next, TOnError&& on_error, TOnCompleted&& on_completed)
29 : on_next{std::forward<TOnNext>(on_next)}
30 , on_error{std::forward<TOnError>(on_error)}
31 , on_completed{std::forward<TOnCompleted>(on_completed)}
35 RPP_NO_UNIQUE_ADDRESS OnNext on_next{};
36 RPP_NO_UNIQUE_ADDRESS OnError on_error{};
37 RPP_NO_UNIQUE_ADDRESS OnCompleted on_completed{};
41 static bool is_disposed()
noexcept {
return false; }
48 std::invocable<Type> OnNext,
49 std::invocable<const std::exception_ptr&> OnError,
50 std::invocable<> OnCompleted>
55 std::decay_t<OnError>,
56 std::decay_t<OnCompleted>>
60 std::decay_t<OnError>,
61 std::decay_t<OnCompleted>>{
62 std::forward<OnNext>(on_next),
63 std::forward<OnError>(on_error),
64 std::forward<OnCompleted>(on_completed)};
67 template<constraint::decayed_type Type,
68 std::invocable<Type> OnNext,
69 std::invocable<const std::exception_ptr&> OnError,
70 std::invocable<> OnCompleted>
74 OnCompleted&& on_completed) -> lambda_observer_with_external_disposable<Type,
76 std::decay_t<OnError>,
77 std::decay_t<OnCompleted>>
79 return lambda_observer_with_external_disposable<Type,
81 std::decay_t<OnError>,
82 std::decay_t<OnCompleted>>{
84 std::forward<OnNext>(on_next),
85 std::forward<OnError>(on_error),
86 std::forward<OnCompleted>(on_completed)};
Definition constraints.hpp:22
disposable_wrapper_impl< interface_composite_disposable > composite_disposable_wrapper
Wrapper to keep "composite" disposable. Specialization of rpp::disposable_wrapper_impl.
Definition fwd.hpp:41
disposable_wrapper_impl< interface_disposable > disposable_wrapper
Wrapper to keep "simple" disposable. Specialization of rpp::disposable_wrapper_impl.
Definition fwd.hpp:34
observer< Type, details::observers::lambda_strategy< Type, OnNext, OnError, OnCompleted > > lambda_observer
Observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via...
Definition fwd.hpp:119
auto make_lambda_observer(OnNext &&on_next, OnError &&on_error={}, OnCompleted &&on_completed={}) -> lambda_observer< Type, std::decay_t< OnNext >, std::decay_t< OnError >, std::decay_t< OnCompleted > >
Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on t...
Definition lambda_observer.hpp:51