ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
rpp::observer< Type, Strategy > Class Template Reference

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...

Public Types

using DisposableStrategy = details::observers::deduce_optimal_disposables_strategy_t<Strategy::preferred_disposables_mode>
 
using Base = details::observer_impl<Type, Strategy, DisposableStrategy>
 
- Public Types inherited from rpp::details::observer_impl< Type, Strategy, details::observers::deduce_optimal_disposables_strategy_t< Strategy::preferred_disposables_mode > >
using on_next_lvalue
 
using on_next_rvalue
 

Public Member Functions

template<typename... Args>
requires constraint::is_constructible_from<Strategy, Args&&...>
 observer (DisposableStrategy strategy, Args &&... args)
 
template<typename... Args>
requires (constraint::is_constructible_from<Strategy, Args && ...> && !rpp::constraint::variadic_decayed_same_as<observer, Args...>)
 observer (Args &&... args)
 
 observer (const observer &)=delete
 
 observer (observer &&) noexcept=default
 
dynamic_observer< Type > as_dynamic () &&
 Convert current observer to type-erased version. Useful if you need to COPY your observer or to store different observers in same container.
 
- Public Member Functions inherited from rpp::details::observer_impl< Type, Strategy, details::observers::deduce_optimal_disposables_strategy_t< Strategy::preferred_disposables_mode > >
void set_upstream (const disposable_wrapper &d) noexcept
 Observable calls this method to pass disposable. Observer disposes this disposable WHEN observer wants to unsubscribe.
 
bool is_disposed () const noexcept
 Observable calls this method to check if observer interested or not in emissions.
 
void on_next (const Type &v) const noexcept
 Observable calls this method to notify observer about new value.
 
void on_next (Type &&v) const noexcept
 Observable calls this method to notify observer about new value.
 
void on_error (const std::exception_ptr &err) const noexcept
 Observable calls this method to notify observer about some error during generation next data.
 
void on_completed () const noexcept
 Observable calls this method to notify observer about completion of emissions.
 

Additional Inherited Members

- Static Public Attributes inherited from rpp::details::observer_impl< Type, Strategy, details::observers::deduce_optimal_disposables_strategy_t< Strategy::preferred_disposables_mode > >
static constexpr auto preferred_disposables_mode
 
- Protected Member Functions inherited from rpp::details::observer_impl< Type, Strategy, details::observers::deduce_optimal_disposables_strategy_t< Strategy::preferred_disposables_mode > >
 observer_impl (DisposablesStrategy strategy, Args &&... args)
 

Detailed Description

template<constraint::decayed_type Type, constraint::observer_strategy< Type > Strategy>
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.

Warning
By default observer is not copyable, only movable. If you need to COPY your observer, you need to convert it to rpp::dynamic_observer via rpp::observer::as_dynamic
Expected that observer would be subscribed only to ONE observable ever. It can keep internal state and track it it was disposed or not. So, subscribing same observer multiple time follows unspecified behavior.
If you are passing disposable to ctor, then state of this disposable would be used used (if empty disposable or disposed -> observer is disposed by default)
It is expected that members of this observer are called in a SERIAL manner. This means no parallel or concurrent calls are allowed—only serial calls or those guarded under a lock.
Template Parameters
Typeof value this observer can handle
Strategyused to provide logic over observer's callbacks

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