ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
fwd.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/memory_model.hpp>
14#include <rpp/schedulers/constraints.hpp>
15#include <rpp/schedulers/fwd.hpp>
16#include <rpp/utils/function_traits.hpp>
17#include <rpp/subscribers/constraints.hpp>
18#include <rpp/utils/operator_declaration.hpp>
19
20#include <rpp/observables/fwd.hpp>
21
22namespace rpp::details
23{
24struct create_tag;
25struct empty_tag;
26struct never_tag;
27struct error_tag;
28struct just_tag;
29struct from_tag;
30struct interval_tag;
31
32} // rpp::observable::details
33
34namespace rpp::observable
35{
36//**************************** CREATE ****************//
37template<constraint::decayed_type Type, constraint::on_subscribe_fn<Type> OnSubscribeFn>
38auto create(OnSubscribeFn&& on_subscribe) requires rpp::details::is_header_included<rpp::details::create_tag, Type, OnSubscribeFn>;
39
40template<utils::is_callable OnSubscribeFn, constraint::decayed_type Type = utils::extract_subscriber_type_t<utils::function_argument_t<OnSubscribeFn>>>
41 requires constraint::on_subscribe_fn<OnSubscribeFn, Type>
42auto create(OnSubscribeFn&& on_subscribe) requires rpp::details::is_header_included<rpp::details::create_tag, Type, OnSubscribeFn>;
43
44//**************************** EMPTY *****************//
45template<constraint::decayed_type Type>
46auto empty() requires rpp::details::is_header_included<rpp::details::empty_tag, Type>;
47
48//**************************** NEVER *****************//
49template<constraint::decayed_type Type>
50auto never() requires rpp::details::is_header_included<rpp::details::never_tag, Type>;
51
52//**************************** ERROR *****************//
53template<constraint::decayed_type Type>
54auto error(const std::exception_ptr& err) requires rpp::details::is_header_included<rpp::details::error_tag, Type>;
55
56//************************** FROM ***********************//
57template<memory_model memory_model = memory_model::use_stack, typename T, typename ...Ts>
58auto just(const schedulers::constraint::scheduler auto& scheduler, T&& item, Ts&& ...items) requires (rpp::details::is_header_included<rpp::details::just_tag, T, Ts...> && (constraint::decayed_same_as<T, Ts> && ...));
59
60template<memory_model memory_model = memory_model::use_stack, typename T, typename ...Ts>
61auto just(T&& item, Ts&& ...items) requires (rpp::details::is_header_included<rpp::details::just_tag, T, Ts...> && (constraint::decayed_same_as<T, Ts> && ...));
62
63template<memory_model memory_model= memory_model::use_stack, schedulers::constraint::scheduler TScheduler = schedulers::trampoline>
64auto from_iterable(constraint::iterable auto&& iterable, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included <rpp::details::from_tag, TScheduler > ;
65
66template<memory_model memory_model = memory_model::use_stack>
67auto from_callable(std::invocable<> auto&& callable) requires rpp::details::is_header_included<rpp::details::from_tag, decltype(callable)>;
68
69//************************ INTERVAL *********************//
70template<schedulers::constraint::scheduler TScheduler = schedulers::trampoline>
71auto interval(schedulers::duration period, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>;
72
73template<schedulers::constraint::scheduler TScheduler = schedulers::trampoline>
74auto interval(schedulers::duration first_delay, schedulers::duration period, const TScheduler& scheduler = TScheduler{}) requires rpp::details::is_header_included<rpp::details::interval_tag, TScheduler>;
75} // namespace rpp::observable
76
77namespace rpp
78{
79namespace source = observable;
80} // namespace rpp
auto empty()
Creates rpp::specific_observable that emits no items but terminates normally.
Definition: empty.hpp:32
auto interval(schedulers::duration period, const TScheduler &scheduler=TScheduler{})
Creates rpp::specific_observable which emits sequence of size_t every provided time interval.
Definition: interval.hpp:43
auto from_callable(std::invocable<> auto &&callable)
Creates rpp::specific_observable that calls provided callable and emits resulting value of this calla...
Definition: from.hpp:227
auto error(const std::exception_ptr &err)
Creates rpp::specific_observable that emits no items and terminates with an error.
Definition: error.hpp:34
auto never()
Creates rpp::specific_observable that emits no items and does not terminate.
Definition: never.hpp:31
auto create(OnSubscribeFn &&on_subscribe)
Creates rpp::specific_observable with passed action as OnSubscribe.
Definition: create.hpp:40
auto from_iterable(constraint::iterable auto &&iterable, const TScheduler &scheduler)
Creates rpp::specific_observable that emits a items from provided iterable.
Definition: from.hpp:207