For each item from this observable until on_next occurs on the trigger observable or until the specified time, emit them from the new observable that is returned. take_until takes (TriggerObservable, optional Coordination) or (TimePoint, optional Coordination)
More...
Go to the source code of this file.
|
template<class... AN> |
auto | rxcpp::operators::take_until (AN &&...an) -> operator_factory< take_until_tag, AN... > |
| For each item from this observable until on_next occurs on the trigger observable or until the specified time, emit them from the new observable that is returned. take_until takes (TriggerObservable, optional Coordination) or (TimePoint, optional Coordination) More...
|
|
For each item from this observable until on_next occurs on the trigger observable or until the specified time, emit them from the new observable that is returned. take_until takes (TriggerObservable, optional Coordination) or (TimePoint, optional Coordination)
- Template Parameters
-
TriggerSource | the type of the trigger observable. |
TimePoint | the type of the time interval. |
Coordination | the type of the scheduler (optional). |
- Parameters
-
t | an observable whose first emitted item will stop emitting items from the source observable. |
when | a time point when the returned observable will stop emitting items. |
cn | the scheduler to use for scheduling the items (optional). |
- Returns
- An observable that emits the items emitted by the source observable until trigger observable emitted or the time runs out.
- Sample Code
auto values = source.take_until(trigger);
values.
[](long v){printf("OnNext: %ld\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
- Sample Code
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Source emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
printf("[thread %s] Trigger emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
values.
[](long v){printf("[thread %s] OnNext: %ld\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 47481267428736] Source emits, value = 1
[thread 47481313687296] OnNext: 1
[thread 47481267428736] Source emits, value = 2
[thread 47481313687296] OnNext: 2
[thread 47481267428736] Source emits, value = 3
[thread 47481313687296] OnNext: 3
[thread 47481267428736] Trigger emits, value = 1
[thread 47481313687296] OnCompleted
[thread 47481267428736] Finish task
- Sample Code
auto values = source.take_until(std::chrono::steady_clock::now() + std::chrono::milliseconds(25));
values.
[](long v){printf("OnNext: %ld\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
- Sample Code
printf("[thread %s] Start task\n", get_pid().c_str());
printf("[thread %s] Source emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
auto values = source.take_until(scheduler.now() + std::chrono::milliseconds(25), scheduler);
values.
[](long v){printf("[thread %s] OnNext: %ld\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 47481267428736] Source emits, value = 1
[thread 47481313687296] OnNext: 1
[thread 47481267428736] Source emits, value = 2
[thread 47481313687296] OnNext: 2
[thread 47481267428736] Source emits, value = 3
[thread 47481313687296] OnNext: 3
[thread 47481313687296] OnCompleted
[thread 47481267428736] Finish task
#define RXCPP_OPERATORS_RX_TAKE_UNTIL_HPP |