Returns an observable that sends values in the range first
-last
by adding step
to the previous value. The values are sent on the specified scheduler.
More...
Go to the source code of this file.
|
template<class T > |
auto | rxcpp::sources::range (T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> observable< T, detail::range< T, identity_one_worker >> |
| Returns an observable that executes the specified function when a subscriber subscribes to it. More...
|
|
template<class T , class Coordination > |
auto | rxcpp::sources::range (T first, T last, std::ptrdiff_t step, Coordination cn) -> observable< T, detail::range< T, Coordination >> |
| Returns an observable that executes the specified function when a subscriber subscribes to it. More...
|
|
template<class T , class Coordination > |
auto | rxcpp::sources::range (T first, T last, Coordination cn) -> typename std::enable_if< is_coordination< Coordination >::value, observable< T, detail::range< T, Coordination >>>::type |
| Returns an observable that executes the specified function when a subscriber subscribes to it. More...
|
|
template<class T , class Coordination > |
auto | rxcpp::sources::range (T first, Coordination cn) -> typename std::enable_if< is_coordination< Coordination >::value, observable< T, detail::range< T, Coordination >>>::type |
| Returns an observable that executes the specified function when a subscriber subscribes to it. More...
|
|
Returns an observable that sends values in the range first
-last
by adding step
to the previous value. The values are sent on the specified scheduler.
- Template Parameters
-
T | the type of the values that this observable emits |
Coordination | the type of the scheduler (optional) |
- Parameters
-
first | first value to send (optional) |
last | last value to send (optional) |
step | value to add to the previous value to get the next value (optional) |
cn | the scheduler to run the generator loop on (optional) |
- Returns
- Observable that sends values in the range
first
-last
by adding step
to the previous value using the specified scheduler.
- Sample Code
printf("[thread %s] Start task\n", get_pid().c_str());
auto s = values.
map([](
int v) {
return std::make_tuple(get_pid(), v);});
s.
[](const std::string pid, int v) {
printf("[thread %s] OnNext: %d\n", pid.c_str(), v);
}),
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 47481267428736] Start task
[thread 47481303181056] OnNext: 1
[thread 47481303181056] OnNext: 2
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task
An alternative way to specify the scheduler for emitted values is to use observable::subscribe_on operator printf("[thread %s] Start task\n", get_pid().c_str());
auto s = values.
map([](
int v) {
return std::make_tuple(get_pid(), v);});
s.
[](const std::string pid, int v) {
printf("[thread %s] OnNext: %d\n", pid.c_str(), v);
}),
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 47481267428736] Start task
[thread 47481303181056] OnNext: 1
[thread 47481303181056] OnNext: 2
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task
#define RXCPP_SOURCES_RX_RANGE_HPP |