Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted.
More...
Go to the source code of this file.
|
template<class... AN> |
auto | rxcpp::operators::timestamp (AN &&...an) -> operator_factory< timestamp_tag, AN... > |
| Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted. More...
|
|
Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted.
- Template Parameters
-
Coordination | the type of the scheduler (optional). |
- Parameters
-
coordination | the scheduler to manage timeout for each event (optional). |
- Returns
- Observable that emits a pair: { item emitted by the source observable, time_point representing the current value of the clock }.
- Sample Code
typedef rxcpp::schedulers::scheduler::clock_type::time_point time_point;
using namespace std::chrono;
.timestamp()
.take(3);
values.
[&](std::pair<long, time_point> v) {
long long int ms = duration_cast<milliseconds>(v.second - start).
count();
printf("OnNext: %ld @%lldms\n", v.first, ms);
},
[](std::exception_ptr ep) {
try {
std::rethrow_exception(ep);
} catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
},
[]() { printf("OnCompleted\n"); });
OnNext: 1 @0ms
OnNext: 2 @100ms
OnNext: 3 @200ms
OnCompleted
#define RXCPP_OPERATORS_RX_TIMESTAMP_HPP |