Observer subscribes on Observable and obtains values provided by Observable.
More...
|
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.
|
|
|
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<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.
|
|
Observer subscribes on Observable and obtains values provided by Observable.
Observer is kind of wrapper over 3 core functions:
- on_next(T) - callback with new emission provided by observable
- on_error(err) - failure termination callback with reason of failure of observable (why observable can't continue processing)
- on_completed() - succeed termination callback - observable is done, no any future emissions from this
- See also
- https://reactivex.io/documentation/observable.html
◆ lambda_observer
template<constraint::decayed_type Type, std::invocable< Type > OnNext, std::invocable< const std::exception_ptr & > OnError, std::invocable<> OnCompleted>
Observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.
- Template Parameters
-
Type | of value this observer can handle |
OnNext | is type of callback to handle on_next(const Type&) and on_next(Type&&) |
OnError | is type of callback to handle on_error(const std::exception_ptr&) |
OnCompleted | is type of callback to handle on_completed() |
◆ 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<>>
Constructs observer specialized with passed callbacks. Most easiesest way to construct observer "on the fly" via lambdas and etc.
- Template Parameters
-
Type | of value this observer can handle |
- Parameters
-
d | is disposable to attach to resulting observer |
on_next | is callback to handle on_next(const Type&) and on_next(Type&&) |
on_error | is callback to handle on_error(const std::exception_ptr&) |
on_completed | is 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
-
Type | of value this observer can handle |
- Parameters
-
on_next | is callback to handle on_next(const Type&) and on_next(Type&&) |
on_error | is callback to handle on_error(const std::exception_ptr&) |
on_completed | is callback to handle on_completed() |