1 2 #include "rxcpp/rx.hpp" 3 // create alias' to simplify code 4 // these are owned by the user so that 5 // conflicts can be managed by the user. 6 namespace rx=rxcpp; 7 namespace rxsub=rxcpp::subjects; 8 namespace rxu=rxcpp::util; 9 10 #include <cctype> 11 #include <clocale> 12 13 // At this time, RxCpp will fail to compile if the contents 14 // of the std namespace are merged into the global namespace 15 // DO NOT USE: 'using namespace std;' 16 main()17int main() 18 { 19 auto keys = rx::observable<>::create<int>( 20 [](rx::subscriber<int> dest){ 21 for (;;) { 22 int key = std::cin.get(); 23 dest.on_next(key); 24 } 25 }). 26 publish(); 27 28 auto a = keys. 29 filter([](int key){return std::tolower(key) == 'a';}); 30 31 auto g = keys. 32 filter([](int key){return std::tolower(key) == 'g';}); 33 34 a.merge(g). 35 subscribe([](int key){ 36 std::cout << key << std::endl; 37 }); 38 39 // run the loop in create 40 keys.connect(); 41 42 return 0; 43 } 44