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

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\n
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

◆ RXCPP_OPERATORS_RX_DELAY_HPP

#define RXCPP_OPERATORS_RX_DELAY_HPP
rxcpp::observe_on_new_thread
observe_on_one_worker observe_on_new_thread()
Definition: rx-observe_on.hpp:328
rxcpp::operators::tap
auto tap(AN &&... an) -> operator_factory< tap_tag, AN... >
Definition: rx-tap.hpp:121
rxcpp::operators::delay
auto delay(AN &&... an) -> operator_factory< delay_tag, AN... >
Definition: rx-delay.hpp:182
rxcpp::identity_current_thread
identity_one_worker identity_current_thread()
Definition: rx-coordination.hpp:175
rxcpp::operators::as_blocking
auto as_blocking() -> detail::blocking_factory
Definition: rx-subscribe.hpp:144
rxcpp::operators::take
auto take(AN &&... an) -> operator_factory< take_tag, AN... >
Definition: rx-take.hpp:133
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::sources::interval
auto interval(Duration period) -> typename std::enable_if< detail::defer_interval< Duration, identity_one_worker >::value, typename detail::defer_interval< Duration, identity_one_worker >::observable_type >::type
Definition: rx-interval.hpp:113