34 virtual void onNext(
const T&) = 0;
47 template <
class N,
class E,
class C>
48 static std::unique_ptr<Observer>
create(
49 N&& onNextFn,
E&& onErrorFn,
C&& onCompletedFn)
51 return std::make_unique<FunctionObserver<T>>(
52 std::forward<N>(onNextFn),
53 std::forward<E>(onErrorFn),
54 std::forward<C>(onCompletedFn));
59 template <
class N,
class E>
60 static std::unique_ptr<Observer>
create(N&& onNextFn,
E&& onErrorFn) {
61 return std::make_unique<FunctionObserver<T>>(
62 std::forward<N>(onNextFn),
63 std::forward<E>(onErrorFn),
70 static std::unique_ptr<Observer>
create(N&& onNextFn) {
71 return std::make_unique<FunctionObserver<T>>(
72 std::forward<N>(onNextFn),
82 typedef std::function<void(const T&)>
OnNext;
83 typedef std::function<void(Error)>
OnError;
88 template <
class N = OnNext,
class E = OnError,
class C = OnCompleted>
90 : onNext_(
std::forward<N>(n)),
91 onError_(
std::forward<
E>(e)),
92 onCompleted_(
std::forward<
C>(
c))
96 if (onNext_) onNext_(val);
100 if (onError_) onError_(e);
104 if (onCompleted_) onCompleted_();
void onError(Error e) override
std::function< void(const T &)> OnNext
virtual void onError(Error)=0
static std::unique_ptr< Observer > create(N &&onNextFn)
virtual void onCompleted()=0
void onCompleted() override
virtual ~Observer()=default
static std::unique_ptr< Observer > create(N &&onNextFn, E &&onErrorFn)
FunctionObserver(N &&n, E &&e, C &&c)
std::function< void(Error)> OnError
static std::unique_ptr< Observer > create(N &&onNextFn, E &&onErrorFn, C &&onCompletedFn)
void onNext(const T &val) override
std::function< void()> OnCompleted
virtual void onNext(const T &)=0