ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
base_subject.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#pragma once
11
12#include <rpp/utils/constraints.hpp>
13#include <rpp/sources/create.hpp>
14#include <rpp/subscriptions/composite_subscription.hpp>
15#include <rpp/subjects/fwd.hpp>
16
17namespace rpp::subjects::details
18{
19struct subject_tag{};
20
21template<rpp::constraint::decayed_type T, subject_strategy<T> Strategy>
23{
24public:
25 auto get_subscriber() const
26 {
27 return m_strategy.get_subscriber();
28 }
29
30 auto get_observable() const
31 {
32 return source::create<T>([strategy = this->m_strategy](const auto& sub)
33 {
34 strategy.on_subscribe(sub);
35 });
36 }
37
38protected:
39 base_subject(auto&& ...args)
40 : m_strategy{std::forward<decltype(args)>(args)...} {}
41
42 const Strategy& get_strategy() const { return m_strategy; }
43
44private:
45 Strategy m_strategy{};
46};
47} // namespace rpp::subjects::details
Definition: base_subject.hpp:23
Definition: base_subject.hpp:19