Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

チュートリアル

一番簡単な使い方

    
    rxcpp::observable<int> obs = rxcpp::observable<>::create<int>
    (
     [=](rxcpp::subscriber<int> s) {
         s.on_next(100);
         s.on_next(200);
         s.on_next(300);
         s.on_completed();
     }
     );
    
    
    auto x = obs.flat_map([=](int x) {
        return rxcpp::observable<>::just(x * 1000);
    }).as_dynamic()
    .flat_map([=](int x) {
        return rxcpp::observable<>::just("hoge");
    }).as_dynamic();
    
    auto l = x.subscribe([=](std::string txt){
        std::cout << txt << std::endl;
    });
    
    std::async(std::launch::async, [l]() {
        usleep(5*1000*1000);
        std::cout << "**unsubscribe**" << std::endl;
        l.unsubscribe();
    });