ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
rpp::specific_observer< T, OnNext, OnError, OnCompleted > Class Template Reference

Observer specified with specific template types of callbacks to avoid extra heap usage. More...

#include <specific_observer.hpp>

Inheritance diagram for rpp::specific_observer< T, OnNext, OnError, OnCompleted >:
rpp::details::state_observer< T, OnNext, OnError, OnCompleted, States > rpp::details::typed_observer_tag< T > rpp::details::observer_tag

Public Member Functions

template<constraint::on_next_fn< T > TOnNext = utils::empty_function_t<T>, constraint::on_error_fn TOnError = utils::rethrow_error_t, constraint::on_completed_fn TOnCompleted = utils::empty_function_t<>>
 specific_observer (TOnNext &&on_next={}, TOnError &&on_error={}, TOnCompleted &&on_completed={})
 
 specific_observer (constraint::on_next_fn< T > auto &&on_next, constraint::on_completed_fn auto &&on_completed)
 
auto as_dynamic () const &
 Converting current rpp::specific_observer to rpp::dynamic_observer alternative with erasing of type (and using heap)
 
auto as_dynamic () &&
 
- Public Member Functions inherited from rpp::details::state_observer< T, OnNext, OnError, OnCompleted, States >
template<typename ... TStates>
requires (constraint::decayed_same_as<States, TStates> && ...)
 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, 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<>>
class rpp::specific_observer< T, OnNext, OnError, OnCompleted >

Observer specified with specific template types of callbacks to avoid extra heap usage.

It has better performance comparing to rpp::dynamic_observer due to using stack instead of heap as long as possible. It is default return type of all operators

Template Parameters
Tis type of value handled by this observer
OnNexttype of on_next callback
OnErrortype of on_error callback
OnCompletedtype of on_completed callback

Member Function Documentation

◆ as_dynamic()

template<constraint::decayed_type T, 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<>>
auto rpp::specific_observer< T, OnNext, OnError, OnCompleted >::as_dynamic ( ) const &
inline

Converting current rpp::specific_observer to rpp::dynamic_observer alternative with erasing of type (and using heap)

Returns
converted rpp::dynamic_observer

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