summaryrefslogtreecommitdiff
path: root/Rx/v2/examples/doxygen/debounce.cpp
blob: b90183d87270efb909779bdada99886749518070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "rxcpp/rx.hpp"

#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

SCENARIO("debounce sample"){
    printf("//! [debounce sample]\n");
    using namespace std::chrono;
    auto scheduler = rxcpp::identity_current_thread();
    auto start = scheduler.now();
    auto period = milliseconds(10);
    auto values = rxcpp::observable<>::interval(start, period, scheduler).
        take(4).
        debounce(period);
    values.
        subscribe(
            [](long v) { printf("OnNext: %ld\n", v); },
            []() { printf("OnCompleted\n"); });
    printf("//! [debounce sample]\n");
}