• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "rxcpp/rx.hpp"
2 
3 #include "rxcpp/rx-test.hpp"
4 #include "catch.hpp"
5 
6 SCENARIO("switch_on_next sample"){
7     printf("//! [switch_on_next sample]\n");
8     auto base = rxcpp::observable<>::interval(std::chrono::milliseconds(30)).
9         take(3).
__anon01d19d5b0102(long)10         map([](long){
11             return rxcpp::observable<>::interval(std::chrono::milliseconds(10)).as_dynamic();
12         });
13     auto values = base.switch_on_next().take(10);
14     values.
15         subscribe(
__anon01d19d5b0202(long v)16             [](long v){printf("OnNext: %ld\n", v);},
__anon01d19d5b0302()17             [](){printf("OnCompleted\n");});
18     printf("//! [switch_on_next sample]\n");
19 }
20 
21 SCENARIO("threaded switch_on_next sample"){
22     printf("//! [threaded switch_on_next sample]\n");
23     auto base = rxcpp::observable<>::interval(std::chrono::milliseconds(30)).
24         take(3).
__anon01d19d5b0402(long)25         map([](long){
26             return rxcpp::observable<>::interval(std::chrono::milliseconds(10), rxcpp::observe_on_event_loop()).as_dynamic();
27         });
28     auto values = base.switch_on_next(rxcpp::observe_on_new_thread()).take(10);
29     values.
30         as_blocking().
31         subscribe(
__anon01d19d5b0502(long v)32             [](long v){printf("OnNext: %ld\n", v);},
__anon01d19d5b0602()33             [](){printf("OnCompleted\n");});
34     printf("//! [threaded switch_on_next sample]\n");
35 }
36