ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
rpp::dynamic_observer< T > Class Template Referencefinal

Dynamic (type-erased) version of observer (comparing to specific_observer) More...

#include <dynamic_observer.hpp>

Inheritance diagram for rpp::dynamic_observer< T >:
rpp::details::dynamic_state_observer< T > rpp::details::state_observer< T, utils::forwarding_on_next_for_pointer, utils::forwarding_on_error_for_pointer, utils::forwarding_on_completed_for_pointer, std::shared_ptr< dynamic_observer_state_base< T > > > rpp::details::typed_observer_tag< T > rpp::details::observer_tag

Public Member Functions

template<constraint::on_next_fn< T > OnNext = utils::empty_function_t<T>, constraint::on_error_fn OnError = utils::rethrow_error_t, constraint::on_completed_fn OnCompleted = utils::empty_function_t<>>
 dynamic_observer (OnNext &&on_next={}, OnError &&on_error={}, OnCompleted &&on_completed={})
 
 dynamic_observer (constraint::on_next_fn< T > auto &&on_next, constraint::on_completed_fn auto &&on_completed)
 
template<constraint::observer_of_type< T > TObserver>
requires (!std::is_same_v<std::decay_t<TObserver>, dynamic_observer<T>>)
 dynamic_observer (TObserver &&obs)
 
const dynamic_observer< T > & as_dynamic () const
 Do nothing for rpp::dynamic_observer. Created only for unification of interfaces with rpp::specific_observer.
 
- Public Member Functions inherited from rpp::details::dynamic_state_observer< T >
 dynamic_state_observer (std::invocable< T, States... > auto &&on_next, std::invocable< std::exception_ptr, States... > auto &&on_error, std::invocable< States... > auto &&on_completed, TStates &&... states)
 
 dynamic_state_observer (std::shared_ptr< details::dynamic_observer_state_base< T > > state)
 
 dynamic_state_observer (TObserver &&obs)
 
- Public Member Functions inherited from rpp::details::state_observer< T, utils::forwarding_on_next_for_pointer, utils::forwarding_on_error_for_pointer, utils::forwarding_on_completed_for_pointer, std::shared_ptr< dynamic_observer_state_base< T > > >
 state_observer (std::invocable< T, States... > auto &&on_next, std::invocable< std::exception_ptr, States... > auto &&on_error, std::invocable< States... > auto &&on_completed, TStates &&...states)
 
void on_next (const T &v) const
 Observable calls this methods to notify observer about new value.
 
void on_next (T &&v) const
 Observable calls this methods to notify observer about new value.
 
void on_error (const std::exception_ptr &err) const
 Observable calls this method to notify observer about some error during generation next data.
 
void on_completed () const
 Observable calls this method to notify observer about finish of work.
 

Detailed Description

template<constraint::decayed_type T>
class rpp::dynamic_observer< T >

Dynamic (type-erased) version of observer (comparing to specific_observer)

It uses type-erasure mechanism to hide types of OnNext, OnError and OnCompleted callbacks. But it has higher cost in the terms of performance due to usage of heap. Use it only when you need to store observer as member variable or make copy of original subscriber. In other cases prefer using "auto" to avoid converting to dynamic_observer

Template Parameters
Tis type of value handled by this observer

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