blob: 2c50e9805d773628b2a1e36e0362375b4ea0b306 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#pragma once
#if !defined(RXCPP_SOURCES_RX_CREATE_HPP)
#define RXCPP_SOURCES_RX_CREATE_HPP
#include "../rx-includes.hpp"
namespace rxcpp {
namespace sources {
namespace detail {
template<class T, class OnSubscribe>
struct create : public source_base<T>
{
typedef create<T, OnSubscribe> this_type;
typedef typename std::decay<OnSubscribe>::type on_subscribe_type;
on_subscribe_type on_subscribe_function;
create(on_subscribe_type os)
: on_subscribe_function(std::move(os))
{
}
template<class Subscriber>
void on_subscribe(Subscriber o) const {
on_exception(
[&](){
this->on_subscribe_function(o);
return true;
},
o);
}
};
}
template<class T, class OnSubscribe>
auto create(OnSubscribe os)
-> observable<T, detail::create<T, OnSubscribe>> {
return observable<T, detail::create<T, OnSubscribe>>(
detail::create<T, OnSubscribe>(std::move(os)));
}
}
}
#endif
|