From fba0f2d04f8d6ac53994a994353f6ae3cb6a2219 Mon Sep 17 00:00:00 2001 From: Kirk Shoop Date: Tue, 20 May 2014 08:35:26 -0700 Subject: add synchronize subject and fix lifetime issues This finally forced a rewrite of subscription. pretty happy with the result. flat map removed all sync and takes a new parameter that is applied to every source and can be used to synchronize them also added multicast --- Rx/v2/src/rxcpp/rx-observer.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Rx/v2/src/rxcpp/rx-observer.hpp') diff --git a/Rx/v2/src/rxcpp/rx-observer.hpp b/Rx/v2/src/rxcpp/rx-observer.hpp index 6b573ae..b6bad50 100644 --- a/Rx/v2/src/rxcpp/rx-observer.hpp +++ b/Rx/v2/src/rxcpp/rx-observer.hpp @@ -366,6 +366,31 @@ auto make_observer_dynamic(OnNext&& on, OnError&& oe, OnCompleted&& oc) dynamic_observer(make_observer(std::forward(on), std::forward(oe), std::forward(oc)))); } + +template +auto on_exception(const F& f, const OnError& c) + -> typename std::enable_if::value, rxu::detail::maybe>::type { + rxu::detail::maybe r; + try { + r.reset(f()); + } catch (...) { + c(std::current_exception()); + } + return r; +} + +template +auto on_exception(const F& f, const Subscriber& s) + -> typename std::enable_if::value, rxu::detail::maybe>::type { + rxu::detail::maybe r; + try { + r.reset(f()); + } catch (...) { + s.on_error(std::current_exception()); + } + return r; +} + } #endif -- cgit v1.2.3