ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
share.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
11#pragma once
12
13#include <rpp/operators/fwd.hpp>
14
15#include <rpp/operators/multicast.hpp>
16#include <rpp/subjects/publish_subject.hpp>
17
18namespace rpp::operators::details
19{
20 template<template<typename> typename Subject>
21 struct share_t
22 {
23 template<rpp::constraint::observable TObservable>
24 auto operator()(TObservable&& observable) const
25 {
26 return template_multicast_t<Subject>{}(std::forward<TObservable>(observable)).ref_count();
27 }
28 };
29} // namespace rpp::operators::details
30
31namespace rpp::operators
32{
48 template<template<typename> typename Subject>
49 auto share()
50 {
52 }
53} // namespace rpp::operators
Base class for any observable used in RPP. It handles core callbacks of observable.
Definition observable.hpp:38
auto share()
Shares single subscription to original observable between multiple observers.
Definition share.hpp:49
auto ref_count()
Forces rpp::connectable_observable to behave like common observable.
Definition ref_count.hpp:29
Definition share.hpp:22