ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
Observers

Observer subscribes on Observable and obtains values provided by Observable. More...

Concepts

concept  rpp::constraint::observer_strategy
 Concept to define strategy to override observer behavior. Strategy must be able to handle all observer's callbacks: on_next/on_error/on_completed.
 

Classes

class  rpp::dynamic_observer< Type >
 Type-erased version of the rpp::observer. Any observer can be converted to dynamic_observer via rpp::observer::as_dynamic member function. More...
 
class  rpp::observer< Type, Strategy >
 Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this class would be passed to subscribe of observable. More...
 

Typedefs

template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError, std::invocable<> OnCompleted>
using rpp::lambda_observer = observer<Type, details::observers::lambda_strategy<Type, OnNext, OnError, OnCompleted>>
 Observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.
 

Functions

template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError = rpp::utils::rethrow_error_t, std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
auto rpp::make_lambda_observer (OnNext &&on_next, OnError &&on_error={}, OnCompleted &&on_completed={}) -> lambda_observer< Type, std::decay_t< OnNext >, std::decay_t< OnError >, std::decay_t< OnCompleted > >
 Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.
 
template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError = rpp::utils::rethrow_error_t, std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
auto rpp::make_lambda_observer (const rpp::composite_disposable_wrapper &d, OnNext &&on_next, OnError &&on_error={}, OnCompleted &&on_completed={}) -> lambda_observer_with_disposable< Type, std::decay_t< OnNext >, std::decay_t< OnError >, std::decay_t< OnCompleted > >
 Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.
 

Detailed Description

Observer subscribes on Observable and obtains values provided by Observable.

Observer is kind of wrapper over 3 core functions:

Typedef Documentation

◆ lambda_observer

template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError, std::invocable<> OnCompleted>
using rpp::lambda_observer = observer<Type, details::observers::lambda_strategy<Type, OnNext, OnError, OnCompleted>>

Observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.

Template Parameters
Typeof value this observer can handle
OnNextis type of callback to handle on_next(const Type&) and on_next(Type&&)
OnErroris type of callback to handle on_error(const std::exception_ptr&)
OnCompletedis type of callback to handle on_completed()

Function Documentation

◆ make_lambda_observer() [1/2]

template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError = rpp::utils::rethrow_error_t, std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
auto rpp::make_lambda_observer ( const rpp::composite_disposable_wrapper & d,
OnNext && on_next,
OnError && on_error = {},
OnCompleted && on_completed = {} ) -> lambda_observer_with_disposable<Type, std::decay_t<OnNext>, std::decay_t<OnError>, std::decay_t<OnCompleted>>

Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.

Template Parameters
Typeof value this observer can handle
Parameters
dis disposable to attach to resulting observer
on_nextis callback to handle on_next(const Type&) and on_next(Type&&)
on_erroris callback to handle on_error(const std::exception_ptr&)
on_completedis callback to handle on_completed()

◆ make_lambda_observer() [2/2]

template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError = rpp::utils::rethrow_error_t, std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
auto rpp::make_lambda_observer ( OnNext && on_next,
OnError && on_error = {},
OnCompleted && on_completed = {} ) -> lambda_observer<Type, std::decay_t<OnNext>, std::decay_t<OnError>, std::decay_t<OnCompleted>>

Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.

Template Parameters
Typeof value this observer can handle
Parameters
on_nextis callback to handle on_next(const Type&) and on_next(Type&&)
on_erroris callback to handle on_error(const std::exception_ptr&)
on_completedis callback to handle on_completed()