proxygen
wangle::FunctionObserver< T > Struct Template Reference

#include <Observer.h>

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

Public Types

typedef std::function< void(const T &)> OnNext
 
typedef std::function< void(Error)> OnError
 
typedef std::function< void()> OnCompleted
 

Public Member Functions

template<class N = OnNext, class E = OnError, class C = OnCompleted>
 FunctionObserver (N &&n, E &&e, C &&c)
 
void onNext (const T &val) override
 
void onError (Error e) override
 
void onCompleted () override
 
- Public Member Functions inherited from wangle::Observer< T >
virtual ~Observer ()=default
 

Protected Attributes

OnNext onNext_
 
OnError onError_
 
OnCompleted onCompleted_
 

Additional Inherited Members

- Static Public Member Functions inherited from wangle::Observer< T >
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::FunctionObserver< T >

An observer that uses std::function callbacks. You don't really want to make one of these directly - instead use the Observer::create() methods.

Definition at line 27 of file Observer.h.

Member Typedef Documentation

template<class T >
typedef std::function<void()> wangle::FunctionObserver< T >::OnCompleted

Definition at line 84 of file Observer.h.

template<class T >
typedef std::function<void(Error)> wangle::FunctionObserver< T >::OnError

Definition at line 83 of file Observer.h.

template<class T >
typedef std::function<void(const T&)> wangle::FunctionObserver< T >::OnNext

Definition at line 82 of file Observer.h.

Constructor & Destructor Documentation

template<class T >
template<class N = OnNext, class E = OnError, class C = OnCompleted>
wangle::FunctionObserver< T >::FunctionObserver ( N &&  n,
E &&  e,
C &&  c 
)
inline

We don't need any fancy overloads of this constructor because that's what Observer::create() is for.

Definition at line 89 of file Observer.h.

90  : onNext_(std::forward<N>(n)),
91  onError_(std::forward<E>(e)),
92  onCompleted_(std::forward<C>(c))
93  {}
OnCompleted onCompleted_
Definition: Observer.h:110
char c

Member Function Documentation

template<class T >
void wangle::FunctionObserver< T >::onCompleted ( )
inlineoverridevirtual

Implements wangle::Observer< T >.

Definition at line 103 of file Observer.h.

103  {
104  if (onCompleted_) onCompleted_();
105  }
OnCompleted onCompleted_
Definition: Observer.h:110
template<class T >
void wangle::FunctionObserver< T >::onError ( Error  e)
inlineoverridevirtual

Implements wangle::Observer< T >.

Definition at line 99 of file Observer.h.

99  {
100  if (onError_) onError_(e);
101  }
template<class T >
void wangle::FunctionObserver< T >::onNext ( const T val)
inlineoverridevirtual

Implements wangle::Observer< T >.

Definition at line 95 of file Observer.h.

95  {
96  if (onNext_) onNext_(val);
97  }
double val
Definition: String.cpp:273

Member Data Documentation

template<class T >
OnCompleted wangle::FunctionObserver< T >::onCompleted_
protected

Definition at line 110 of file Observer.h.

template<class T >
OnError wangle::FunctionObserver< T >::onError_
protected

Definition at line 109 of file Observer.h.

template<class T >
OnNext wangle::FunctionObserver< T >::onNext_
protected

Definition at line 108 of file Observer.h.


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