For each given observable subscribe. For each item emitted from all of the given observables, deliver from the new observable that is returned.
More...
Go to the source code of this file.
For each given observable subscribe. For each item emitted from all of the given observables, deliver from the new observable that is returned.
There are 2 variants of the operator:
- The source observable emits nested observables, nested observables are merged.
- The source observable and the arguments v0...vn are used to provide the observables to merge.
- Template Parameters
-
Coordination | the type of the scheduler (optional). |
Value0 | ... (optional). |
ValueN | types of source observables (optional). |
- Parameters
-
cn | the scheduler to synchronize sources from different contexts (optional). |
v0 | ... (optional). |
vn | source observables (optional). |
- Returns
- Observable that emits items that are the result of flattening the observables emitted by the source observable.
If scheduler is omitted, identity_current_thread is used.
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
printf("[thread %s] Timer2 fired\n", get_pid().c_str());
return 2;
});
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
values.
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 3015701568] Timer1 fired
[thread 3015701568] OnNext: 1
[thread 3015701568] Timer2 fired
[thread 3015701568] OnNext: 2
[thread 3015701568] Timer3 fired
[thread 3015701568] OnNext: 3
[thread 3015701568] OnCompleted
[thread 3070107664] Finish task
- Sample Code\n
auto values = base.merge();
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 3
OnNext: 2
OnNext: 1
OnCompleted
- Sample Code\n
auto values = o1.merge(o2, o3);
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 3
OnNext: 2
OnNext: 1
OnCompleted
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
printf("[thread %s] Timer2 fired\n", get_pid().c_str());
return 2;
});
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
values.
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 3015701568] Timer1 fired
[thread 3015701568] OnNext: 1
[thread 3015701568] Timer2 fired
[thread 3015701568] OnNext: 2
[thread 3015701568] Timer3 fired
[thread 3015701568] OnNext: 3
[thread 3015701568] OnCompleted
[thread 3070107664] Finish task
◆ RXCPP_OPERATORS_RX_MERGE_HPP
#define RXCPP_OPERATORS_RX_MERGE_HPP |
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