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.
|
template<class... AN> |
auto | rxcpp::operators::merge (AN &&...an) -> operator_factory< merge_tag, AN... > |
| For each given observable subscribe. For each item emitted from all of the given observables, deliver from the new observable that is returned. More...
|
|
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
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 47481267428736] Start task
[thread 47481303181056] Timer1 fired
[thread 47481303181056] OnNext: 1
[thread 47481303181056] Timer2 fired
[thread 47481303181056] OnNext: 2
[thread 47481303181056] Timer3 fired
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task
- Sample Code
auto values = base.
merge();
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 3
OnNext: 2
OnNext: 1
OnCompleted
- Sample Code
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
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 47481267428736] Start task
[thread 47481303181056] Timer1 fired
[thread 47481303181056] OnNext: 1
[thread 47481303181056] Timer2 fired
[thread 47481303181056] OnNext: 2
[thread 47481303181056] Timer3 fired
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task
#define RXCPP_OPERATORS_RX_MERGE_HPP |