ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
debounce.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// https://www.boost.org/LICENSE_1_0.txt)
7//
8// Project home: https://github.com/victimsnino/ReactivePlusPlus
9//
10
11#pragma once
12
13#include <rpp/schedulers/constraints.hpp>
14#include <rpp/observables/details/member_overload.hpp>
15
16namespace rpp::details
17{
18struct debounce_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type, schedulers::constraint::scheduler TScheduler>
24struct debounce_impl;
25
26template<constraint::decayed_type Type, typename SpecificObservable>
27struct member_overload<Type, SpecificObservable, debounce_tag>
28{
65 template<schedulers::constraint::scheduler TScheduler>
66 auto debounce(schedulers::duration period,const TScheduler& scheduler = TScheduler{}) const & requires is_header_included<debounce_tag, TScheduler>
67 {
68 return static_cast<const SpecificObservable*>(this)->template lift<Type>(debounce_impl<Type, TScheduler>{period, scheduler});
69 }
70
71 template<schedulers::constraint::scheduler TScheduler>
72 auto debounce(schedulers::duration period, const TScheduler& scheduler = TScheduler{}) && requires is_header_included<debounce_tag, TScheduler>
73 {
74 return std::move(*static_cast<SpecificObservable*>(this)).template lift<Type>(debounce_impl<Type, TScheduler>{period, scheduler});
75 }
76};
77} // namespace rpp::details
Definition: debounce.hpp:145
Definition: member_overload.hpp:19