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( __anond1f6ab530102(long v)13 [](long v){printf("OnNext: %ld\n", v);}, __anond1f6ab530202()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()); __anond1f6ab530302(long v)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 }); __anond1f6ab530402(long v)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( __anond1f6ab530502(long v)35 [](long v){printf("[thread %s] OnNext: %ld\n", get_pid().c_str(), v);}, __anond1f6ab530602()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