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)
39 observer.on_next(std::forward<T>(v));
40 last_emission_time_point = now;
44 void on_error(
const std::exception_ptr& err)
const { observer.on_error(err); }
46 void on_completed()
const { observer.on_completed(); }
50 bool is_disposed()
const {
return observer.is_disposed(); }
54 struct throttle_t : lift_operator<throttle_t<Scheduler>, rpp::schedulers::duration>
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;
auto throttle(rpp::schedulers::duration period)
Emit emission from an Observable and then ignore subsequent values during duration of time.
Definition throttle.hpp:98