1 #include "rxcpp/rx.hpp" 2 3 #include "rxcpp/rx-test.hpp" 4 #include "catch.hpp" 5 6 SCENARIO("from sample"){ 7 printf("//! [from sample]\n"); 8 auto values = rxcpp::observable<>::from(1, 2, 3); 9 values. 10 subscribe( __anon5cdaa9880102(int v)11 [](int v){printf("OnNext: %d\n", v);}, __anon5cdaa9880202()12 [](){printf("OnCompleted\n");}); 13 printf("//! [from sample]\n"); 14 } 15 16 #include "main.hpp" 17 18 SCENARIO("threaded from sample"){ 19 printf("//! [threaded from sample]\n"); 20 printf("[thread %s] Start task\n", get_pid().c_str()); __anon5cdaa9880302(int v)21 auto values = rxcpp::observable<>::from(rxcpp::observe_on_new_thread(), 1, 2, 3).map([](int v){ 22 printf("[thread %s] Emit value: %d\n", get_pid().c_str(), v); 23 return v; 24 }); 25 values. 26 as_blocking(). 27 subscribe( __anon5cdaa9880402(int v)28 [](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);}, __anon5cdaa9880502()29 [](){printf("[thread %s] OnCompleted\n", get_pid().c_str());}); 30 printf("[thread %s] Finish task\n", get_pid().c_str()); 31 printf("//! [threaded from sample]\n"); 32 } 33 34