Home | History | Annotate | Download | only in doxygen
      1 #include "rxcpp/rx.hpp"
      2 
      3 #include "rxcpp/rx-test.hpp"
      4 #include "catch.hpp"
      5 
      6 SCENARIO("timepoint timer sample"){
      7     printf("//! [timepoint timer sample]\n");
      8     auto start = std::chrono::steady_clock::now() + std::chrono::milliseconds(1);
      9     auto values = rxcpp::observable<>::timer(start);
     10     values.
     11         subscribe(
     12             [](int v){printf("OnNext: %d\n", v);},
     13             [](){printf("OnCompleted\n");});
     14     printf("//! [timepoint timer sample]\n");
     15 }
     16 
     17 SCENARIO("duration timer sample"){
     18     printf("//! [duration timer sample]\n");
     19     auto period = std::chrono::milliseconds(1);
     20     auto values = rxcpp::observable<>::timer(period);
     21     values.
     22         subscribe(
     23             [](int v){printf("OnNext: %d\n", v);},
     24             [](){printf("OnCompleted\n");});
     25     printf("//! [duration timer sample]\n");
     26 }
     27 
     28 SCENARIO("threaded timepoint timer sample"){
     29     printf("//! [threaded timepoint timer sample]\n");
     30     auto scheduler = rxcpp::observe_on_new_thread();
     31     auto start = scheduler.now() + std::chrono::milliseconds(1);
     32     auto values = rxcpp::observable<>::timer(start, scheduler);
     33     values.
     34         as_blocking().
     35         subscribe(
     36             [](int v){printf("OnNext: %d\n", v);},
     37             [](){printf("OnCompleted\n");});
     38     printf("//! [threaded timepoint timer sample]\n");
     39 }
     40 
     41 SCENARIO("threaded duration timer sample"){
     42     printf("//! [threaded duration timer sample]\n");
     43     auto scheduler = rxcpp::observe_on_new_thread();
     44     auto period = std::chrono::milliseconds(1);
     45     auto values = rxcpp::observable<>::timer(period, scheduler);
     46     values.
     47         as_blocking().
     48         subscribe(
     49             [](int v){printf("OnNext: %d\n", v);},
     50             [](){printf("OnCompleted\n");});
     51     printf("//! [threaded duration timer sample]\n");
     52 }
     53