13#include <rpp/operators/fwd.hpp>
15#include <rpp/defs.hpp>
16#include <rpp/operators/details/strategy.hpp>
17#include <rpp/schedulers/immediate.hpp>
22namespace rpp::operators::details
24 template<rpp::constra
int::observer TObserver, rpp::schedulers::constra
int::scheduler Scheduler>
27 static constexpr auto preferred_disposables_mode = rpp::details::observers::disposables_mode::None;
29 RPP_NO_UNIQUE_ADDRESS TObserver
observer;
30 rpp::schedulers::duration duration{};
31 mutable std::optional<rpp::schedulers::time_point> last_emission_time_point{};
34 void on_next(T&& v)
const
36 const auto now = rpp::schedulers::utils::get_worker_t<Scheduler>::now();
37 if (!last_emission_time_point || now >= last_emission_time_point.value() + duration)
40 last_emission_time_point = now;
44 void on_error(
const std::exception_ptr& err)
const {
observer.
on_error(err); }
53 template<rpp::schedulers::constra
int::scheduler Scheduler>
58 template<rpp::constra
int::decayed_type T>
61 using result_type = T;
63 template<rpp::constra
int::observer_of_type<result_type> TObserver>
67 template<rpp::details::observables::constra
int::disposables_strategy Prev>
68 using updated_optimal_disposables_strategy = Prev;
72namespace rpp::operators
102 auto throttle(rpp::schedulers::duration period)
void on_next(const Type &v) const noexcept
Observable calls this method to notify observer about new value.
Definition observer.hpp:84
void set_upstream(const disposable_wrapper &d) noexcept
Observable calls this method to pass disposable. Observer disposes this disposable WHEN observer want...
Definition observer.hpp:49
void on_completed() const noexcept
Observable calls this method to notify observer about completion of emissions.
Definition observer.hpp:135
void on_error(const std::exception_ptr &err) const noexcept
Observable calls this method to notify observer about some error during generation next data.
Definition observer.hpp:120
bool is_disposed() const noexcept
Observable calls this method to check if observer interested or not in emissions.
Definition observer.hpp:74
Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this clas...
Definition observer.hpp:172
Definition strategy.hpp:28
auto throttle(rpp::schedulers::duration period)
Emit emission from an Observable and then ignore subsequent values during duration of time.
Definition throttle.hpp:98
Definition throttle.hpp:26
Definition throttle.hpp:60
Definition throttle.hpp:55