ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
create.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/sources/fwd.hpp>
13
14#include <rpp/observables/observable.hpp>
15
16namespace rpp::details
17{
18 template<constraint::decayed_type Type, constraint::on_subscribe<Type> OnSubscribe>
20 {
21 using value_type = Type;
23
24 RPP_NO_UNIQUE_ADDRESS OnSubscribe subscribe;
25 };
26} // namespace rpp::details
27
28namespace rpp
29{
30 template<constraint::decayed_type Type, constraint::on_subscribe<Type> OnSubscribe>
32} // namespace rpp
33
34namespace rpp::source
35{
59 template<constraint::decayed_type Type, constraint::on_subscribe<Type> OnSubscribe>
60 auto create(OnSubscribe&& on_subscribe)
61 {
62 return create_observable<Type, std::decay_t<OnSubscribe>>{std::forward<OnSubscribe>(on_subscribe)};
63 }
64
88 template<typename OnSubscribe, constraint::decayed_type Type>
89 auto create(OnSubscribe&& on_subscribe)
90 {
91 return create<Type>(std::forward<OnSubscribe>(on_subscribe));
92 }
93} // namespace rpp::source
Base class for any observable used in RPP. It handles core callbacks of observable.
Definition observable.hpp:38
auto create(OnSubscribe &&on_subscribe)
Construct observable specialized with passed callback function. Most easiesest way to construct obser...
Definition create.hpp:57
Definition create.hpp:20
Definition disposables_strategy.hpp:19