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-delay.hpp File Reference

Return an observable that emits each item emitted by the source observable after the specified delay. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-delay.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< delay_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_DELAY_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::delay (AN &&...an) -> operator_factory< delay_tag, AN... >
 Return an observable that emits each item emitted by the source observable after the specified delay. More...
 

Detailed Description

Return an observable that emits each item emitted by the source observable after the specified delay.

Template Parameters
Durationthe type of time interval
Coordinationthe type of the scheduler
Parameters
periodthe period of time each item is delayed
coordinationthe scheduler for the delays
Returns
Observable that emits each item emitted by the source observable after the specified delay.
Sample Code
using namespace std::chrono;
auto scheduler = rxcpp::identity_current_thread();
auto start = scheduler.now();
auto period = milliseconds(10);
const auto next = [=](const char* s) {
return [=](long v){
auto t = duration_cast<milliseconds>(scheduler.now() - start);
long long int ms = t.count();
printf("[%s @ %lld] OnNext: %ld\n", s, ms, v);
};
};
auto values = rxcpp::observable<>::interval(start, period, scheduler).
take(4).
tap(next("interval")).
values.
next(" delayed"),
[](){printf("OnCompleted\n");});
[interval @ 0] OnNext: 1
[interval @ 10] OnNext: 2
[ delayed @ 10] OnNext: 1
[interval @ 20] OnNext: 3
[ delayed @ 20] OnNext: 2
[interval @ 30] OnNext: 4
[ delayed @ 30] OnNext: 3
[ delayed @ 40] OnNext: 4
OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_DELAY_HPP