ReactivePlusPlus
ReactiveX implementation for C++20
Toggle main menu visibility
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/AlexInLog/ReactivePlusPlus
9
10
#pragma once
11
12
#include <rpp/sources/fwd.hpp>
13
14
#include <rpp/observables/observable.hpp>
15
16
namespace
rpp::details
17
{
18
template
<constra
int
::decayed_type Type, constra
int
::on_subscribe<Type> OnSubscribe>
19
struct
create_strategy
20
{
21
using
value_type = Type;
22
using
optimal_disposables_strategy = rpp::details::observables::default_disposables_strategy;
23
24
RPP_NO_UNIQUE_ADDRESS OnSubscribe subscribe;
25
};
26
}
// namespace rpp::details
27
28
namespace
rpp
29
{
30
template
<constra
int
::decayed_type Type, constra
int
::on_subscribe<Type> OnSubscribe>
31
using
create_observable =
observable<Type, details::create_strategy<Type, OnSubscribe>
>;
32
}
// namespace rpp
33
34
namespace
rpp::source
35
{
57
* @see https://reactivex.io/documentation/operators/create.html
58
*/
59
template
<constra
int
::decayed_type Type, constra
int
::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
83
* @snippet create.cpp create with capture
84
*
85
* @ingroup creational_operators
86
* @see https://reactivex.io/documentation/operators/create.html
87
*/
88
template
<
typename
OnSubscribe, constra
int
::decayed_type Type>
89
auto
create
(OnSubscribe&& on_subscribe)
90
{
91
return
create<Type>
(std::forward<OnSubscribe>(on_subscribe));
92
}
93
}
// namespace rpp::source
rpp::observable
Base class for any observable used in RPP. It handles core callbacks of observable.
Definition
observable.hpp:38
rpp::source::create
auto create(OnSubscribe &&on_subscribe)
Construct observable specialized with passed callback function. Most easiesest way to construct obser...
Definition
create.hpp:57
rpp::details::create_strategy
Definition
create.hpp:20
src
rpp
rpp
sources
create.hpp
Generated by
1.17.0