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("skip_until sample"){
      7     printf("//! [skip_until sample]\n");
      8     auto source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7);
      9     auto trigger = rxcpp::observable<>::timer(std::chrono::milliseconds(25));
     10     auto values = source.skip_until(trigger);
     11     values.
     12         subscribe(
     13             [](long v){printf("OnNext: %ld\n", v);},
     14             [](){printf("OnCompleted\n");});
     15     printf("//! [skip_until sample]\n");
     16 }
     17 
     18 #include "main.hpp"
     19 
     20 SCENARIO("threaded skip_until sample"){
     21     printf("//! [threaded skip_until sample]\n");
     22     printf("[thread %s] Start task\n", get_pid().c_str());
     23     auto source = rxcpp::observable<>::interval(std::chrono::milliseconds(10)).take(7).map([](long v){
     24         printf("[thread %s] Source emits, value = %ld\n", get_pid().c_str(), v);
     25         return v;
     26     });
     27     auto trigger = rxcpp::observable<>::timer(std::chrono::milliseconds(25)).map([](long v){
     28         printf("[thread %s] Trigger emits, value = %ld\n", get_pid().c_str(), v);
     29         return v;
     30     });
     31     auto values = source.skip_until(trigger, rxcpp::observe_on_new_thread());
     32     values.
     33         as_blocking().
     34         subscribe(
     35             [](long v){printf("[thread %s] OnNext: %ld\n", get_pid().c_str(), v);},
     36             [](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
     37     printf("[thread %s] Finish task\n", get_pid().c_str());
     38     printf("//! [threaded skip_until sample]\n");
     39 }
     40