RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
rx-create.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 
3 #pragma once
4 
5 #if !defined(RXCPP_SOURCES_RX_CREATE_HPP)
6 #define RXCPP_SOURCES_RX_CREATE_HPP
7 
8 #include "../rx-includes.hpp"
9 
45 namespace rxcpp {
46 
47 namespace sources {
48 
49 namespace detail {
50 
51 template<class T, class OnSubscribe>
52 struct create : public source_base<T>
53 {
54  typedef create<T, OnSubscribe> this_type;
55 
56  typedef rxu::decay_t<OnSubscribe> on_subscribe_type;
57 
58  on_subscribe_type on_subscribe_function;
59 
60  create(on_subscribe_type os)
61  : on_subscribe_function(std::move(os))
62  {
63  }
64 
65  template<class Subscriber>
66  void on_subscribe(Subscriber o) const {
67 
69  [&](){
70  this->on_subscribe_function(o);
71  return true;
72  },
73  o);
74  }
75 };
76 
77 }
78 
81 template<class T, class OnSubscribe>
82 auto create(OnSubscribe os)
85  detail::create<T, OnSubscribe>(std::move(os)));
86 }
87 
88 }
89 
90 }
91 
92 #endif
auto create(OnSubscribe os) -> observable< T, detail::create< T, OnSubscribe >>
Returns an observable that executes the specified function when a subscriber subscribes to it...
Definition: rx-create.hpp:82
Definition: rx-all.hpp:26
a source of values. subscribe or use one of the operator methods that return a new observable...
Definition: rx-observable.hpp:510
auto on_exception(const F &f, const OnError &c) -> typename std::enable_if< detail::is_on_error< OnError >::value, typename detail::maybe_from_result< F >::type >::type
Definition: rx-observer.hpp:639