1 #include "rxcpp/rx.hpp" 2 3 #include "rxcpp/rx-test.hpp" 4 #include "catch.hpp" 5 6 SCENARIO("switch_if_empty sample"){ 7 printf("//! [switch_if_empty sample]\n"); 8 9 auto values = rxcpp::observable<>::empty<int>() 10 .switch_if_empty(rxcpp::observable<>::range(1, 5)); 11 12 values.subscribe( __anond1d45edf0102(int v) 13 [](int v) { printf("OnNext: %d\n", v); }, __anond1d45edf0202() 14 []() { printf("OnCompleted\n"); } ); 15 16 printf("//! [switch_if_empty sample]\n"); 17 } 18 19 SCENARIO("switch_if_empty - operator syntax sample") { 20 using namespace rxcpp; 21 using namespace rxcpp::sources; 22 using namespace rxcpp::operators; 23 24 printf("//! [switch_if_empty - operator syntax sample]\n"); 25 auto values = empty<int>() 26 | switch_if_empty(range(1, 5)); 27 28 values.subscribe( __anond1d45edf0302(int v) 29 [](int v) { printf("OnNext: %d\n", v); }, __anond1d45edf0402() 30 []() { printf("OnCompleted\n"); } ); 31 32 printf("//! [switch_if_empty - operator syntax sample]\n"); 33 } 34