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++.
Classes | Namespaces | Macros | Functions
rx-take_until.hpp File Reference

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...

#include "../rx-includes.hpp"
Include dependency graph for rx-take_until.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rxcpp::member_overload< take_until_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_TAKE_UNTIL_HPP
 

Functions

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...
 

Detailed Description

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
TriggerSourcethe type of the trigger observable.
TimePointthe type of the time interval.
Coordinationthe type of the scheduler (optional).
Parameters
tan observable whose first emitted item will stop emitting items from the source observable.
whena time point when the returned observable will stop emitting items.
cnthe 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 source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7);
auto trigger = rxcpp::observable<>::timer(std::chrono::milliseconds(25));
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());
auto source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7).map([](long v){
printf("[thread %s] Source emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
auto trigger = rxcpp::observable<>::timer(std::chrono::milliseconds(25)).map([](long v){
printf("[thread %s] Trigger emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
auto values = source.take_until(trigger, rxcpp::observe_on_new_thread());
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 source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7);
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());
auto source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7).map([](long v){
printf("[thread %s] Source emits, value = %ld\n", get_pid().c_str(), v);
return v;
});
auto scheduler = rxcpp::observe_on_new_thread();
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

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_TAKE_UNTIL_HPP