ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
timer.hpp
1#pragma once
2
3#include <rpp/sources/fwd.hpp>
4
5#include <rpp/operators/take.hpp>
6#include <rpp/sources/interval.hpp>
7
8namespace rpp::source
9{
24 template<schedulers::constraint::scheduler TScheduler>
25 auto timer(rpp::schedulers::duration when, TScheduler&& scheduler)
26 {
27 return interval(when, rpp::schedulers::duration::zero(), std::forward<TScheduler>(scheduler)) | operators::take(1);
28 }
29
39 template<schedulers::constraint::scheduler TScheduler>
40 auto timer(rpp::schedulers::time_point when, TScheduler&& scheduler)
41 {
42 return interval(when, rpp::schedulers::duration::zero(), std::forward<TScheduler>(scheduler)) | operators::take(1);
43 }
44} // namespace rpp::source
auto interval(rpp::schedulers::duration initial, rpp::schedulers::duration period, TScheduler &&scheduler)
Creates rpp::observable that emits a sequential integer every specified time interval,...
Definition interval.hpp:72
auto timer(rpp::schedulers::duration when, TScheduler &&scheduler)
Creates rpp::observable that emits an integer after a given delay, on the specified scheduler.
Definition timer.hpp:22
auto take(size_t count)
Emit only first count items provided by observable, then send on_completed
Definition take.hpp:92