ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
fwd.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2023 - 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#pragma once
11
12#include <rpp/observers/fwd.hpp>
13
14#include <rpp/observables/details/disposables_strategy.hpp>
15#include <rpp/utils/constraints.hpp>
16#include <rpp/utils/utils.hpp>
17
18namespace rpp::constraint
19{
34 template<typename S, typename T>
36 {
37 strategy.subscribe(std::move(observer))
38 } -> std::same_as<void>;
39
40 typename S::value_type;
41 typename S::optimal_disposables_strategy;
43 };
44} // namespace rpp::constraint
45
46namespace rpp::details::observables
47{
48 template<rpp::constraint::decayed_type Type>
50
51 template<rpp::constraint::decayed_type Type, rpp::constraint::observable_strategy<Type> Strategy>
53
54 template<rpp::constraint::decayed_type Type>
56 {
57 using value_type = Type;
59
60 consteval static void subscribe(const auto&) {}
61 };
62} // namespace rpp::details::observables
63
64namespace rpp::details::observables
65{
66 template<typename TStrategy, typename... TStrategies>
67 class chain;
68} // namespace rpp::details::observables
69
70namespace rpp
71{
72 template<rpp::constraint::decayed_type Type, rpp::constraint::observable_strategy<Type> Strategy>
73 class observable;
74} // namespace rpp
75
76
77namespace rpp::constraint
78{
79 template<typename T>
81} // namespace rpp::constraint
82
83namespace rpp
84{
85 template<rpp::constraint::observable OriginalObservable, typename Subject>
87} // namespace rpp
88
89namespace rpp::utils
90{
91 template<typename T>
92 using extract_observable_type_t = typename rpp::utils::extract_base_type_params_t<T, rpp::observable>::template type_at_index_t<0>;
93} // namespace rpp::utils
94
95namespace rpp::constraint
96{
97 template<typename T, typename Type>
98 concept observable_of_type = observable<T> && std::same_as<utils::extract_observable_type_t<T>, std::decay_t<Type>>;
99
100 template<typename TObservable, typename... TObservables>
101 concept observables_of_same_type = rpp::constraint::observable<TObservable> && (rpp::constraint::observable<TObservables> && ...) && (std::same_as<rpp::utils::extract_observable_type_t<TObservable>, rpp::utils::extract_observable_type_t<TObservables>> && ...);
102
108 template<typename Op, typename Type>
109 concept operator_subscribe = requires(const Op& op, rpp::details::observers::fake_observer<typename std::decay_t<Op>::template operator_traits<Type>::result_type>&& observer, const details::observables::chain<details::observables::fake_strategy<Type>>& chain) {
110 {
111 op.subscribe(std::move(observer), chain)
112 };
113 };
114
120 template<typename Op, typename Type>
121 concept operator_lift = requires(const Op& op, rpp::details::observers::fake_observer<typename std::decay_t<Op>::template operator_traits<Type>::result_type>&& observer) {
122 {
123 op.template lift<Type>(std::move(observer))
125 };
126
133 template<typename Op, typename Type, typename DisposableStrategy>
135 {
136 op.template lift_with_disposables_strategy<Type, DisposableStrategy>(std::move(observer))
138 };
139
140 template<typename Op, typename Type>
141 concept has_operator_traits = requires() {
142 typename std::decay_t<Op>::template operator_traits<Type>;
143 typename std::decay_t<Op>::template operator_traits<Type>::result_type;
144 };
145
146 template<typename Op>
148 typename std::decay_t<Op>::template updated_optimal_disposables_strategy<typename details::observables::default_disposables_strategy>;
149 } && details::observables::constraint::disposables_strategy<typename std::decay_t<Op>::template updated_optimal_disposables_strategy<typename details::observables::default_disposables_strategy>>;
150
162 template<typename Op, typename Type, typename DisposableStrategy>
163 concept operator_ =
167
168} // namespace rpp::constraint
169
170namespace rpp
171{
172 template<constraint::decayed_type Type>
174
175 template<constraint::decayed_type Type, constraint::observable_strategy<Type> Strategy>
177
178 template<constraint::decayed_type KeyType, constraint::decayed_type Type, constraint::observable_strategy<Type> Strategy>
179 class grouped_observable;
180
181 template<constraint::decayed_type Type, rpp::constraint::observable_of_type<Type>... Observables>
182 class variant_observable;
183} // namespace rpp
Extension over rpp::observable with set of blocking operators - it waits till completion of underlyin...
Definition fwd.hpp:176
Extension over raw observable with ability to be manually connected at any time or ref_counting (shar...
Definition fwd.hpp:86
Type-erased version of the rpp::observable. Any observable can be converted to dynamic_observable via...
Definition fwd.hpp:173
Extension over rpp::observable for some "subset" of values from original observable grouped by some k...
Definition grouped_observable.hpp:28
Base class for any observable used in RPP. It handles core callbacks of observable.
Definition observable.hpp:38
Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this clas...
Definition observer.hpp:172
Extension over rpp::observable to provide ability statically keep one of multiple observables.
Definition variant_observable.hpp:54
A concept that defines the requirements for an observable strategy.
Definition fwd.hpp:35
Definition fwd.hpp:80
Definition fwd.hpp:253
Definition fwd.hpp:250
Definition fwd.hpp:163
Same as rpp::constraint::operator_lift but with custom disposables logic. For example,...
Definition fwd.hpp:134
Accept downstream observer and return new upstream (of type Type) observer.
Definition fwd.hpp:121
Simple operator defining logic how to subscribe passed observer to passed observable....
Definition fwd.hpp:109
Definition utils.hpp:48
Definition disposables_strategy.hpp:29