13#include <rpp/operators/fwd.hpp>
15#include <rpp/defs.hpp>
16#include <rpp/operators/details/strategy.hpp>
18namespace rpp::operators::details
20 template<rpp::constra
int::observer TObserver>
23 on_error_resume_next_disposable(TObserver&& observer)
25 , observer(std::move(observer))
29 RPP_NO_UNIQUE_ADDRESS TObserver observer;
32 template<rpp::constra
int::observer TObserver>
35 static constexpr auto preferred_disposables_mode = rpp::details::observers::disposables_mode::None;
37 std::shared_ptr<TObserver> observer;
40 void on_next(T&& v)
const
42 observer->on_next(std::forward<T>(v));
45 void on_error(
const std::exception_ptr& err)
const
47 observer->on_error(err);
50 void on_completed()
const
52 observer->on_completed();
57 bool is_disposed()
const {
return observer->is_disposed(); }
61 template<rpp::constra
int::observer TObserver, rpp::constra
int::decayed_type Selector>
62 struct on_error_resume_next_observer_strategy
64 static constexpr auto preferred_disposables_mode = rpp::details::observers::disposables_mode::None;
66 on_error_resume_next_observer_strategy(TObserver&&
observer,
const Selector& selector)
67 : state{init_state(std::move(
observer))}
72 std::shared_ptr<on_error_resume_next_disposable<TObserver>> state;
73 RPP_NO_UNIQUE_ADDRESS Selector selector;
76 void on_next(T&& v)
const
78 state->observer.on_next(std::forward<T>(v));
81 void on_error(
const std::exception_ptr& err)
const
89 state->observer.on_error(std::current_exception());
94 void on_completed()
const
96 state->observer.on_completed();
104 bool is_disposed()
const {
return state->is_disposed(); }
106 static std::shared_ptr<on_error_resume_next_disposable<TObserver>> init_state(TObserver&&
observer)
110 ptr->observer.set_upstream(d.as_weak());
115 template<rpp::constra
int::decayed_type Selector>
120 template<rpp::constra
int::decayed_type T>
123 using selector_observable_result_type =
124 rpp::utils::extract_observable_type_t<std::invoke_result_t<Selector, std::exception_ptr>>;
128 "Selector observable result type is not the same as T");
130 using result_type = T;
132 template<rpp::constra
int::observer_of_type<result_type> TObserver>
136 template<rpp::details::observables::constra
int::disposables_strategy Prev>
137 using updated_optimal_disposables_strategy = rpp::details::observables::default_disposables_strategy;
141namespace rpp::operators
159 template<
typename Selector>
Disposable which can keep some other sub-disposables. When this root disposable is disposed,...
Definition composite_disposable.hpp:175
Main RPP wrapper over disposables.
Definition disposable_wrapper.hpp:142
Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this clas...
Definition observer.hpp:172
Definition constraints.hpp:19
disposable_wrapper_impl< interface_disposable > disposable_wrapper
Wrapper to keep "simple" disposable. Specialization of rpp::disposable_wrapper_impl.
Definition fwd.hpp:34
auto on_error_resume_next(Selector &&selector)
If an error occurs, take the result from the Selector and subscribe to that instead.
Definition on_error_resume_next.hpp:157
Definition on_error_resume_next.hpp:34
Definition on_error_resume_next.hpp:63
Definition on_error_resume_next.hpp:122
Definition on_error_resume_next.hpp:117