20 #if !defined(RXCPP_OPERATORS_RX_ON_ERROR_RESUME_NEXT_HPP) 21 #define RXCPP_OPERATORS_RX_ON_ERROR_RESUME_NEXT_HPP 23 #include "../rx-includes.hpp" 32 struct on_error_resume_next_invalid_arguments {};
35 struct on_error_resume_next_invalid :
public rxo::operator_base<on_error_resume_next_invalid_arguments<AN...>> {
36 using type = observable<on_error_resume_next_invalid_arguments<
AN...>, on_error_resume_next_invalid<
AN...>>;
39 using on_error_resume_next_invalid_t =
typename on_error_resume_next_invalid<
AN...>::type;
42 template<
class T,
class Selector>
45 typedef rxu::decay_t<T> value_type;
46 typedef rxu::decay_t<Selector> select_type;
47 typedef decltype((*(select_type*)
nullptr)(std::exception_ptr())) fallback_type;
51 : selector(std::move(s))
55 template<
class Subscriber>
56 struct on_error_resume_next_observer
58 typedef on_error_resume_next_observer<Subscriber> this_type;
59 typedef rxu::decay_t<T> value_type;
60 typedef rxu::decay_t<Selector> select_type;
61 typedef decltype((*(select_type*)
nullptr)(std::exception_ptr())) fallback_type;
62 typedef rxu::decay_t<Subscriber> dest_type;
63 typedef observer<T, this_type> observer_type;
65 composite_subscription lifetime;
68 on_error_resume_next_observer(dest_type d, composite_subscription cs, select_type s)
70 , lifetime(std::move(cs))
71 , selector(std::move(s))
75 void on_next(value_type v)
const {
76 dest.on_next(std::move(v));
78 void on_error(std::exception_ptr e)
const {
81 return this->selector(std::move(e));},
83 if (selected.empty()) {
86 selected->subscribe(dest);
88 void on_completed()
const {
92 static subscriber<T, observer_type> make(dest_type d, select_type s) {
93 auto cs = composite_subscription();
94 return make_subscriber<T>(cs, observer_type(this_type(std::move(d), cs, std::move(s))));
98 template<
class Subscriber>
99 auto operator()(Subscriber dest)
const 100 -> decltype(on_error_resume_next_observer<Subscriber>::make(std::move(dest), selector)) {
101 return on_error_resume_next_observer<Subscriber>::make(std::move(dest), selector);
109 template<
class...
AN>
112 return operator_factory<on_error_resume_next_tag,
AN...>(std::make_tuple(std::forward<AN>(an)...));
117 template<
class...
AN>
120 return operator_factory<on_error_resume_next_tag,
AN...>(std::make_tuple(std::forward<AN>(an)...));
128 template<
class Observable,
class Selector,
130 class OnErrorResumeNext = rxo::detail::on_error_resume_next<SourceValue, rxu::decay_t<Selector>>,
132 static auto member(Observable&& o, Selector&& p)
133 -> decltype(o.template lift<Value>(OnErrorResumeNext(std::forward<Selector>(p)))) {
134 return o.template lift<Value>(OnErrorResumeNext(std::forward<Selector>(p)));
137 template<
class...
AN>
138 static operators::detail::on_error_resume_next_invalid_t<
AN...>
member(
const AN&...) {
141 static_assert(
sizeof...(
AN) == 10000,
"on_error_resume_next takes (Selector)");
static operators::detail::on_error_resume_next_invalid_t< AN... > member(const AN &...)
Definition: rx-on_error_resume_next.hpp:138
Definition: rx-all.hpp:26
typename std::decay< T >::type::value_type value_type_t
Definition: rx-util.hpp:35
Definition: rx-operators.hpp:276
Definition: rx-operators.hpp:69
auto switch_on_error(AN &&...an) -> operator_factory< on_error_resume_next_tag, AN... >
If an error occurs, take the result from the Selector and subscribe to that instead.
Definition: rx-on_error_resume_next.hpp:118
auto AN
Definition: rx-finally.hpp:105
Definition: rx-operators.hpp:47
auto on_error_resume_next(AN &&...an) -> operator_factory< on_error_resume_next_tag, AN... >
If an error occurs, take the result from the Selector and subscribe to that instead.
Definition: rx-on_error_resume_next.hpp:110
auto on_exception(const F &f, const OnError &c) -> typename std::enable_if< detail::is_on_error< OnError >::value, typename detail::maybe_from_result< F >::type >::type
Definition: rx-observer.hpp:639
static auto member(Observable &&o, Selector &&p) -> decltype(o.template lift< Value >(OnErrorResumeNext(std::forward< Selector >(p))))
Definition: rx-on_error_resume_next.hpp:132