// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. #pragma once /*! \file rx-connect_forever.hpp \brief takes a connectable_observable source and calls connect during the construction of the expression. This means that the source starts running without any subscribers and continues running after all subscriptions have been unsubscribed. \return An observable that emitting the items from its source. */ #if !defined(RXCPP_OPERATORS_RX_CONNECT_FOREVER_HPP) #define RXCPP_OPERATORS_RX_CONNECT_FOREVER_HPP #include "../rx-includes.hpp" namespace rxcpp { namespace operators { namespace detail { template struct connect_forever_invalid_arguments {}; template struct connect_forever_invalid : public rxo::operator_base> { using type = observable, connect_forever_invalid>; }; template using connect_forever_invalid_t = typename connect_forever_invalid::type; template struct connect_forever : public operator_base { typedef rxu::decay_t source_type; source_type source; explicit connect_forever(source_type o) : source(std::move(o)) { source.connect(); } template void on_subscribe(Subscriber&& o) const { source.subscribe(std::forward(o)); } }; } /*! @copydoc rx-connect_forever.hpp */ template auto connect_forever(AN&&... an) -> operator_factory { return operator_factory(std::make_tuple(std::forward(an)...)); } } template<> struct member_overload { template>, class SourceValue = rxu::value_type_t, class ConnectForever = rxo::detail::connect_forever>, class Value = rxu::value_type_t, class Result = observable > static Result member(ConnectableObservable&& o) { return Result(ConnectForever(std::forward(o))); } template static operators::detail::connect_forever_invalid_t member(AN...) { std::terminate(); return {}; static_assert(sizeof...(AN) == 10000, "connect_forever takes no arguments"); } }; } #endif