1 #include "rxcpp/rx.hpp" 2 3 #include "rxcpp/rx-test.hpp" 4 #include "catch.hpp" 5 6 SCENARIO("timeout sample"){ 7 printf("//! [timeout sample]\n"); 8 9 using namespace std::chrono; 10 auto values = rxcpp::observable<>::interval(milliseconds(100)) 11 .take(3) 12 .concat(rxcpp::observable<>::interval(milliseconds(500))) 13 .timeout(milliseconds(200)); 14 values. 15 subscribe( __anon78b90ed60102(long v) 16 [](long v) { printf("OnNext: %ld\n", v); }, __anon78b90ed60202(std::exception_ptr ep) 17 [](std::exception_ptr ep) { 18 try { 19 std::rethrow_exception(ep); 20 } catch (const rxcpp::timeout_error& ex) { 21 printf("OnError: %s\n", ex.what()); 22 } 23 }, __anon78b90ed60302() 24 []() { printf("OnCompleted\n"); }); 25 printf("//! [timeout sample]\n"); 26 } 27