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++.
Static Public Member Functions | List of all members
rxcpp::observable< void, void > Class Reference

typed as rxcpp::observable<>, this is a collection of factory methods that return an observable. More...

#include <rx-observable.hpp>

Static Public Member Functions

template<class T , class OnSubscribe >
static auto create (OnSubscribe os) -> decltype(rxs::create< T >(std::move(os)))
 
template<class T >
static auto range (T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> decltype(rxs::range< T >(first, last, step, identity_current_thread()))
 
template<class T , class Coordination >
static auto range (T first, T last, std::ptrdiff_t step, Coordination cn) -> decltype(rxs::range< T >(first, last, step, std::move(cn)))
 
template<class T , class Coordination >
static auto range (T first, T last, Coordination cn) -> decltype(rxs::range< T >(first, last, std::move(cn)))
 
template<class T , class Coordination >
static auto range (T first, Coordination cn) -> decltype(rxs::range< T >(first, std::move(cn)))
 
template<class T >
static auto never () -> decltype(rxs::never< T >())
 
template<class ObservableFactory >
static auto defer (ObservableFactory of) -> decltype(rxs::defer(std::move(of)))
 
template<class... AN>
static auto interval (rxsc::scheduler::clock_type::duration period, AN **...) -> decltype(rxs::interval(period))
 
template<class Coordination >
static auto interval (rxsc::scheduler::clock_type::duration period, Coordination cn) -> decltype(rxs::interval(period, std::move(cn)))
 
template<class... AN>
static auto interval (rxsc::scheduler::clock_type::time_point initial, rxsc::scheduler::clock_type::duration period, AN **...) -> decltype(rxs::interval(initial, period))
 
template<class Coordination >
static auto interval (rxsc::scheduler::clock_type::time_point initial, rxsc::scheduler::clock_type::duration period, Coordination cn) -> decltype(rxs::interval(initial, period, std::move(cn)))
 
template<class... AN>
static auto timer (rxsc::scheduler::clock_type::time_point at, AN **...) -> decltype(rxs::timer(at))
 
template<class... AN>
static auto timer (rxsc::scheduler::clock_type::duration after, AN **...) -> decltype(rxs::timer(after))
 
template<class Coordination >
static auto timer (rxsc::scheduler::clock_type::time_point when, Coordination cn) -> decltype(rxs::timer(when, std::move(cn)))
 
template<class Coordination >
static auto timer (rxsc::scheduler::clock_type::duration when, Coordination cn) -> decltype(rxs::timer(when, std::move(cn)))
 
template<class Collection >
static auto iterate (Collection c) -> decltype(rxs::iterate(std::move(c), identity_current_thread()))
 
template<class Collection , class Coordination >
static auto iterate (Collection c, Coordination cn) -> decltype(rxs::iterate(std::move(c), std::move(cn)))
 
template<class T >
static auto from () -> decltype(rxs::from< T >())
 
template<class T , class Coordination >
static auto from (Coordination cn) -> typename std::enable_if< is_coordination< Coordination >::value, decltype(rxs::from< T >(std::move(cn)))>::type
 
template<class Value0 , class... ValueN>
static auto from (Value0 v0, ValueN... vn) -> typename std::enable_if<!is_coordination< Value0 >::value, decltype(rxs::from(v0, vn...))>::type
 
template<class Coordination , class Value0 , class... ValueN>
static auto from (Coordination cn, Value0 v0, ValueN... vn) -> typename std::enable_if< is_coordination< Coordination >::value, decltype(rxs::from(std::move(cn), v0, vn...))>::type
 
template<class T >
static auto just (T v) -> decltype(rxs::just(std::move(v)))
 
template<class T , class Coordination >
static auto just (T v, Coordination cn) -> decltype(rxs::just(std::move(v), std::move(cn)))
 
template<class Observable , class Value0 , class... ValueN>
static auto start_with (Observable o, Value0 v0, ValueN... vn) -> decltype(rxs::start_with(std::move(o), std::move(v0), std::move(vn)...))
 
template<class T >
static auto empty () -> decltype(from< T >())
 
template<class T , class Coordination >
static auto empty (Coordination cn) -> decltype(from< T >(std::move(cn)))
 
template<class T , class Exception >
static auto error (Exception &&e) -> decltype(rxs::error< T >(std::forward< Exception >(e)))
 
template<class T , class Exception , class Coordination >
static auto error (Exception &&e, Coordination cn) -> decltype(rxs::error< T >(std::forward< Exception >(e), std::move(cn)))
 
template<class ResourceFactory , class ObservableFactory >
static auto scope (ResourceFactory rf, ObservableFactory of) -> decltype(rxs::scope(std::move(rf), std::move(of)))
 

Detailed Description

typed as rxcpp::observable<>, this is a collection of factory methods that return an observable.

Create a new type of observable
Sample Code\n
s.on_next(1);
s.on_next(2);
});
ints.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnCompleted
Create an observable that emits a range of values
Sample Code\n
auto values1 = rxcpp::observable<>::range(1, 5);
values1.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnNext: 4
OnNext: 5
OnCompleted
Create an observable that emits nothing / generates an error / immediately completes
Sample Code\n
values.
take_until(std::chrono::steady_clock::now() + std::chrono::milliseconds(10)).
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnCompleted
auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source"));
values.
[](int v){printf("OnNext: %d\n", v);},
printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
OnError: Error from source
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnCompleted
Create an observable that generates new observable for each subscriber
Sample Code\n
auto observable_factory = [](){return rxcpp::observable<>::range(1, 3);};
auto values = rxcpp::observable<>::defer(observable_factory);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
Create an observable that emits items every specified interval of time
Sample Code\n
auto start = std::chrono::steady_clock::now() + std::chrono::milliseconds(1);
auto period = std::chrono::milliseconds(1);
auto values = rxcpp::observable<>::interval(start, period);
values.
take(3).
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
Create an observable that emits items in the specified interval of time
Sample Code\n
auto period = std::chrono::milliseconds(1);
auto values = rxcpp::observable<>::timer(period);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnCompleted
Create an observable that emits all items from a collection
Sample Code\n
std::array< int, 3 > a={{1, 2, 3}};
auto values = rxcpp::observable<>::iterate(a);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
Create an observable that emits a set of specified items
Sample Code\n
auto values = rxcpp::observable<>::from(1, 2, 3);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
Create an observable that emits a single item
Sample Code\n
auto values = rxcpp::observable<>::just(1);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnCompleted
Create an observable that emits a set of items and then subscribes to another observable
Sample Code\n
auto observable = rxcpp::observable<>::range(10, 12);
auto values = rxcpp::observable<>::start_with(observable, 1, 2, 3);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnNext: 10
OnNext: 11
OnNext: 12
OnCompleted
Create an observable that generates a new observable based on a generated resource for each subscriber
Sample Code\n
auto resource_factory = [](){return resource(rxcpp::util::to_vector({1, 2, 3, 4, 5}));};
auto observable_factory = [](resource res){return rxcpp::observable<>::iterate(res.get());};
auto values = rxcpp::observable<>::scope(resource_factory, observable_factory);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnNext: 4
OnNext: 5
OnCompleted

Member Function Documentation

◆ create()

template<class T , class OnSubscribe >
static auto rxcpp::observable< void, void >::create ( OnSubscribe  os) -> decltype(rxs::create<T>(std::move(os)))
inlinestatic

◆ defer()

template<class ObservableFactory >
static auto rxcpp::observable< void, void >::defer ( ObservableFactory  of) -> decltype(rxs::defer(std::move(of)))
inlinestatic

◆ empty() [1/2]

template<class T >
static auto rxcpp::observable< void, void >::empty ( ) -> decltype(from<T>())
inlinestatic

◆ empty() [2/2]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::empty ( Coordination  cn) -> decltype(from<T>(std::move(cn)))
inlinestatic

◆ error() [1/2]

template<class T , class Exception >
static auto rxcpp::observable< void, void >::error ( Exception &&  e) -> decltype(rxs::error<T>(std::forward<Exception>(e)))
inlinestatic

◆ error() [2/2]

template<class T , class Exception , class Coordination >
static auto rxcpp::observable< void, void >::error ( Exception &&  e,
Coordination  cn 
) -> decltype(rxs::error<T>(std::forward<Exception>(e), std::move(cn)))
inlinestatic

◆ from() [1/4]

template<class T >
static auto rxcpp::observable< void, void >::from ( ) -> decltype( rxs::from<T>())
inlinestatic

Returns an observable that sends an empty set of values and then completes.

Template Parameters
Tthe type of elements (not) to be sent
Returns
Observable that sends an empty set of values and then completes.

This is a degenerate case of rxcpp::observable<void,void>::from(Value0,ValueN...) operator.

Note
This is a degenerate case of from(Value0 v0, ValueN... vn) operator.

◆ from() [2/4]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::from ( Coordination  cn) -> typename std::enable_if<is_coordination<Coordination>::value, decltype( rxs::from<T>(std::move(cn)))>::type
inlinestatic

Returns an observable that sends an empty set of values and then completes, on the specified scheduler.

Template Parameters
Tthe type of elements (not) to be sent
Coordinationthe type of the scheduler
Returns
Observable that sends an empty set of values and then completes.
Note
This is a degenerate case of from(Coordination cn, Value0 v0, ValueN... vn) operator.

◆ from() [3/4]

template<class Coordination , class Value0 , class... ValueN>
static auto rxcpp::observable< void, void >::from ( Coordination  cn,
Value0  v0,
ValueN...  vn 
) -> typename std::enable_if<is_coordination<Coordination>::value, decltype( rxs::from(std::move(cn), v0, vn...))>::type
inlinestatic

◆ from() [4/4]

template<class Value0 , class... ValueN>
static auto rxcpp::observable< void, void >::from ( Value0  v0,
ValueN...  vn 
) -> typename std::enable_if<!is_coordination<Value0>::value, decltype( rxs::from(v0, vn...))>::type
inlinestatic

◆ interval() [1/4]

template<class... AN>
static auto rxcpp::observable< void, void >::interval ( rxsc::scheduler::clock_type::duration  period,
AN **  ... 
) -> decltype(rxs::interval(period))
inlinestatic

◆ interval() [2/4]

template<class Coordination >
static auto rxcpp::observable< void, void >::interval ( rxsc::scheduler::clock_type::duration  period,
Coordination  cn 
) -> decltype(rxs::interval(period, std::move(cn)))
inlinestatic

◆ interval() [3/4]

template<class... AN>
static auto rxcpp::observable< void, void >::interval ( rxsc::scheduler::clock_type::time_point  initial,
rxsc::scheduler::clock_type::duration  period,
AN **  ... 
) -> decltype(rxs::interval(initial, period))
inlinestatic

◆ interval() [4/4]

template<class Coordination >
static auto rxcpp::observable< void, void >::interval ( rxsc::scheduler::clock_type::time_point  initial,
rxsc::scheduler::clock_type::duration  period,
Coordination  cn 
) -> decltype(rxs::interval(initial, period, std::move(cn)))
inlinestatic

◆ iterate() [1/2]

template<class Collection >
static auto rxcpp::observable< void, void >::iterate ( Collection  c) -> decltype(rxs::iterate(std::move(c), identity_current_thread()))
inlinestatic

◆ iterate() [2/2]

template<class Collection , class Coordination >
static auto rxcpp::observable< void, void >::iterate ( Collection  c,
Coordination  cn 
) -> decltype(rxs::iterate(std::move(c), std::move(cn)))
inlinestatic

◆ just() [1/2]

template<class T >
static auto rxcpp::observable< void, void >::just ( v) -> decltype(rxs::just(std::move(v)))
inlinestatic

Returns an observable that sends the specified item to observer and then completes.

Template Parameters
Tthe type of the emitted item
Parameters
vthe value to send
Returns
Observable that sends the specified item to observer and then completes.
Sample Code\n
auto values = rxcpp::observable<>::just(1);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnCompleted

◆ just() [2/2]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::just ( v,
Coordination  cn 
) -> decltype(rxs::just(std::move(v), std::move(cn)))
inlinestatic

Returns an observable that sends the specified item to observer and then completes, on the specified scheduler.

Template Parameters
Tthe type of the emitted item
Coordinationthe type of the scheduler
Parameters
vthe value to send
cnthe scheduler to use for scheduling the items
Returns
Observable that sends the specified item to observer and then completes.
Sample Code\n
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnCompleted

◆ never()

template<class T >
static auto rxcpp::observable< void, void >::never ( ) -> decltype(rxs::never<T>())
inlinestatic

◆ range() [1/4]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::range ( first,
Coordination  cn 
) -> decltype(rxs::range<T>(first, std::move(cn)))
inlinestatic

◆ range() [2/4]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::range ( first,
last,
Coordination  cn 
) -> decltype(rxs::range<T>(first, last, std::move(cn)))
inlinestatic

◆ range() [3/4]

template<class T , class Coordination >
static auto rxcpp::observable< void, void >::range ( first,
last,
std::ptrdiff_t  step,
Coordination  cn 
) -> decltype(rxs::range<T>(first, last, step, std::move(cn)))
inlinestatic

◆ range() [4/4]

template<class T >
static auto rxcpp::observable< void, void >::range ( first = 0,
last = std::numeric_limits<T>::max(),
std::ptrdiff_t  step = 1 
) -> decltype(rxs::range<T>(first, last, step, identity_current_thread()))
inlinestatic

◆ scope()

template<class ResourceFactory , class ObservableFactory >
static auto rxcpp::observable< void, void >::scope ( ResourceFactory  rf,
ObservableFactory  of 
) -> decltype(rxs::scope(std::move(rf), std::move(of)))
inlinestatic

◆ start_with()

template<class Observable , class Value0 , class... ValueN>
static auto rxcpp::observable< void, void >::start_with ( Observable  o,
Value0  v0,
ValueN...  vn 
) -> decltype(rxs::start_with(std::move(o), std::move(v0), std::move(vn)...))
inlinestatic

◆ timer() [1/4]

template<class... AN>
static auto rxcpp::observable< void, void >::timer ( rxsc::scheduler::clock_type::duration  after,
AN **  ... 
) -> decltype(rxs::timer(after))
inlinestatic

◆ timer() [2/4]

template<class Coordination >
static auto rxcpp::observable< void, void >::timer ( rxsc::scheduler::clock_type::duration  when,
Coordination  cn 
) -> decltype(rxs::timer(when, std::move(cn)))
inlinestatic

◆ timer() [3/4]

template<class... AN>
static auto rxcpp::observable< void, void >::timer ( rxsc::scheduler::clock_type::time_point  at,
AN **  ... 
) -> decltype(rxs::timer(at))
inlinestatic

◆ timer() [4/4]

template<class Coordination >
static auto rxcpp::observable< void, void >::timer ( rxsc::scheduler::clock_type::time_point  when,
Coordination  cn 
) -> decltype(rxs::timer(when, std::move(cn)))
inlinestatic


The documentation for this class was generated from the following file:
rxcpp::sources::iterate
auto iterate(Collection c) -> observable< rxu::value_type_t< detail::iterate_traits< Collection >>, detail::iterate< Collection, identity_one_worker >>
Definition: rx-iterate.hpp:160
rxcpp::observable< void, void >::from
static auto from() -> decltype(rxs::from< T >())
Definition: rx-observable.hpp:1683
rxcpp::util::error_ptr
std::shared_ptr< util::detail::error_base > error_ptr
Definition: rx-util.hpp:874
rxcpp::sources::scope
auto scope(ResourceFactory rf, ObservableFactory of) -> observable< rxu::value_type_t< detail::scope_traits< ResourceFactory, ObservableFactory >>, detail::scope< ResourceFactory, ObservableFactory >>
Definition: rx-scope.hpp:114
rxcpp::subscriber
binds an observer that consumes values with a composite_subscription that controls lifetime.
Definition: rx-subscriber.hpp:25
rxcpp::sources::timer
auto timer(TimePointOrDuration when) -> typename std::enable_if< detail::defer_timer< TimePointOrDuration, identity_one_worker >::value, typename detail::defer_timer< TimePointOrDuration, identity_one_worker >::observable_type >::type
Definition: rx-timer.hpp:114
rxcpp::sources::range
auto range(T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> observable< T, detail::range< T, identity_one_worker >>
Definition: rx-range.hpp:119
rxcpp::resource
Definition: rx-subscription.hpp:555
rxcpp::subscriber::on_next
void on_next(V &&v) const
Definition: rx-subscriber.hpp:176
cpplinq::from
linq_driver< iter_cursor< typename util::container_traits< TContainer >::iterator > > from(TContainer &c)
Definition: linq.hpp:556
rxcpp::sources::defer
auto defer(ObservableFactory of) -> observable< rxu::value_type_t< detail::defer_traits< ObservableFactory >>, detail::defer< ObservableFactory >>
Definition: rx-defer.hpp:73
rxcpp::operators::as_blocking
auto as_blocking() -> detail::blocking_factory
Definition: rx-subscribe.hpp:144
rxcpp::operators::take
auto take(AN &&... an) -> operator_factory< take_tag, AN... >
Definition: rx-take.hpp:133
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::sources::interval
auto interval(Duration period) -> typename std::enable_if< detail::defer_interval< Duration, identity_one_worker >::value, typename detail::defer_interval< Duration, identity_one_worker >::observable_type >::type
Definition: rx-interval.hpp:113
rxcpp::subscriber::on_completed
void on_completed() const
Definition: rx-subscriber.hpp:190
rxcpp::util::what
std::string what(std::exception_ptr ep)
Definition: rx-util.hpp:544
rxcpp::operators::take_until
auto take_until(AN &&... an) -> operator_factory< take_until_tag, AN... >
Definition: rx-take_until.hpp:209
rxcpp::observe_on_event_loop
observe_on_one_worker observe_on_event_loop()
Definition: rx-observe_on.hpp:323
rxcpp::observable
a source of values. subscribe or use one of the operator methods that return a new observable,...
Definition: rx-observable.hpp:478
rxcpp::sources::just
auto just(Value0 v0) -> typename std::enable_if<!is_coordination< Value0 >::value, decltype(iterate(*(std::array< Value0, 1 > *) nullptr, identity_immediate()))>::type
Definition: rx-iterate.hpp:267
rxcpp::observable::start_with
auto start_with(AN... an) const
Definition: rx-observable.hpp:1434
rxcpp::util::to_vector
std::vector< T > to_vector(const T(&arr)[size])
Definition: rx-util.hpp:52