proxygen
wangle::Observer< T > Struct Template Referenceabstract

#include <Observer.h>

Inheritance diagram for wangle::Observer< T >:
wangle::FunctionObserver< T > wangle::Subject< T >

Public Member Functions

virtual void onNext (const T &)=0
 
virtual void onError (Error)=0
 
virtual void onCompleted ()=0
 
virtual ~Observer ()=default
 

Static Public Member Functions

template<class N , class E , class C >
static std::unique_ptr< Observercreate (N &&onNextFn, E &&onErrorFn, C &&onCompletedFn)
 
template<class N , class E >
static std::unique_ptr< Observercreate (N &&onNextFn, E &&onErrorFn)
 
template<class N >
static std::unique_ptr< Observercreate (N &&onNextFn)
 

Detailed Description

template<class T>
struct wangle::Observer< T >

Observer interface. You can subclass it, or you can just use create() to use std::functions.

Definition at line 32 of file Observer.h.

Constructor & Destructor Documentation

template<class T>
virtual wangle::Observer< T >::~Observer ( )
virtualdefault

Member Function Documentation

template<class T>
template<class N , class E , class C >
static std::unique_ptr<Observer> wangle::Observer< T >::create ( N &&  onNextFn,
E &&  onErrorFn,
C &&  onCompletedFn 
)
inlinestatic

Create an Observer with std::function callbacks. Handy to make ad-hoc Observers with lambdas.

Templated for maximum perfect forwarding flexibility, but ultimately whatever you pass in has to implicitly become a std::function for the same signature as onNext(), onError(), and onCompleted() respectively. (see the FunctionObserver typedefs)

Definition at line 48 of file Observer.h.

Referenced by incrementer(), makeCOObserver(), makeMOObserver(), makeObserver(), and TEST().

50  {
51  return std::make_unique<FunctionObserver<T>>(
52  std::forward<N>(onNextFn),
53  std::forward<E>(onErrorFn),
54  std::forward<C>(onCompletedFn));
55  }
template<class T>
template<class N , class E >
static std::unique_ptr<Observer> wangle::Observer< T >::create ( N &&  onNextFn,
E &&  onErrorFn 
)
inlinestatic

Create an Observer with only onNext and onError callbacks. onCompleted will just be a no-op.

Definition at line 60 of file Observer.h.

60  {
61  return std::make_unique<FunctionObserver<T>>(
62  std::forward<N>(onNextFn),
63  std::forward<E>(onErrorFn),
64  nullptr);
65  }
template<class T>
template<class N >
static std::unique_ptr<Observer> wangle::Observer< T >::create ( N &&  onNextFn)
inlinestatic

Create an Observer with only an onNext callback. onError and onCompleted will just be no-ops.

Definition at line 70 of file Observer.h.

70  {
71  return std::make_unique<FunctionObserver<T>>(
72  std::forward<N>(onNextFn),
73  nullptr,
74  nullptr);
75  }
template<class T>
virtual void wangle::Observer< T >::onCompleted ( )
pure virtual
template<class T>
virtual void wangle::Observer< T >::onError ( Error  )
pure virtual
template<class T>
virtual void wangle::Observer< T >::onNext ( const T )
pure virtual

The documentation for this struct was generated from the following file: