ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
observe_on.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// TC Wang 2022 - present.
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// https://www.boost.org/LICENSE_1_0.txt)
8//
9// Project home: https://github.com/victimsnino/ReactivePlusPlus
10
11#pragma once
12
13#include <rpp/observables/details/member_overload.hpp>
14#include <rpp/schedulers/constraints.hpp>
15
16namespace rpp::details
17{
18struct observe_on_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type, schedulers::constraint::scheduler TScheduler>
25
26template<constraint::decayed_type Type, typename SpecificObservable>
27struct member_overload<Type, SpecificObservable, observe_on_tag>
28{
54 template<schedulers::constraint::scheduler TScheduler>
55 auto observe_on(TScheduler&& scheduler) const& requires is_header_included<observe_on_tag, TScheduler>
56 {
57 return cast_this()->delay(schedulers::duration{0}, std::forward<TScheduler>(scheduler));
58 }
59
60 template<schedulers::constraint::scheduler TScheduler>
61 auto observe_on(TScheduler&& scheduler) && requires is_header_included<observe_on_tag, TScheduler>
62 {
63 return move_this().delay(schedulers::duration{0}, std::forward<TScheduler>(scheduler));
64 }
65
66private:
67 const SpecificObservable* cast_this() const
68 {
69 return static_cast<const SpecificObservable*>(this);
70 }
71
72 SpecificObservable&& move_this()
73 {
74 return std::move(*static_cast<SpecificObservable*>(this));
75 }
76};
77} // namespace rpp::details
auto observe_on(TScheduler &&scheduler) const &
Emit emissions of observable starting from this point via provided scheduler.
Definition: observe_on.hpp:55
Definition: member_overload.hpp:19
Definition: observe_on.hpp:24