ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
create.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/observables/specific_observable.hpp>
14#include <rpp/sources/fwd.hpp>
15
16#include <type_traits>
17
18IMPLEMENTATION_FILE(create_tag);
19
20namespace rpp::observable
21{
42template<constraint::decayed_type Type, constraint::on_subscribe_fn<Type> OnSubscribeFn>
43auto create(OnSubscribeFn&& on_subscribe) requires rpp::details::is_header_included<rpp::details::create_tag, Type, OnSubscribeFn>
44{
45 using CreatedOnSubscribeFn = std::decay_t<OnSubscribeFn>;
46 return specific_observable<Type, CreatedOnSubscribeFn>{std::forward<OnSubscribeFn>(on_subscribe)};
47}
48
70template<utils::is_callable OnSubscribeFn, constraint::decayed_type Type>
71 requires constraint::on_subscribe_fn<OnSubscribeFn, Type>
72auto create(OnSubscribeFn&& on_subscribe) requires rpp::details::is_header_included<rpp::details::create_tag, Type, OnSubscribeFn>
73{
74 return create<Type>(std::forward<OnSubscribeFn>(on_subscribe));
75}
76} // namespace rpp::observable
auto create(OnSubscribeFn &&on_subscribe)
Creates rpp::specific_observable with passed action as OnSubscribe.
Definition: create.hpp:40