diff options
author | Grigoriy Chudnov <g.chudnov@gmail.com> | 2016-04-12 10:01:40 +0300 |
---|---|---|
committer | Grigoriy Chudnov <g.chudnov@gmail.com> | 2016-04-12 10:01:40 +0300 |
commit | 4e7e721138a6d41d48840e6d2aa0a949c40920c2 (patch) | |
tree | dec20085f8a00cf1feb10528be91e400f5a933da /Rx/v2/examples | |
parent | c7b40011452bd35f00f1dd4cf5c5a0769b615a27 (diff) | |
download | RxCpp-4e7e721138a6d41d48840e6d2aa0a949c40920c2.tar.gz |
add timeout operator
Diffstat (limited to 'Rx/v2/examples')
-rw-r--r-- | Rx/v2/examples/doxygen/timeout.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Rx/v2/examples/doxygen/timeout.cpp b/Rx/v2/examples/doxygen/timeout.cpp new file mode 100644 index 0000000..c61d519 --- /dev/null +++ b/Rx/v2/examples/doxygen/timeout.cpp @@ -0,0 +1,26 @@ +#include "rxcpp/rx.hpp" + +#include "rxcpp/rx-test.hpp" +#include "catch.hpp" + +SCENARIO("timeout sample"){ + printf("//! [timeout sample]\n"); + + using namespace std::chrono; + auto values = rxcpp::observable<>::interval(milliseconds(100)) + .take(3) + .concat(rxcpp::observable<>::interval(milliseconds(500))) + .timeout(milliseconds(200)); + values. + subscribe( + [](long v) { printf("OnNext: %ld\n", v); }, + [](std::exception_ptr ep) { + try { + std::rethrow_exception(ep); + } catch (const rxcpp::timeout_error& ex) { + printf("OnError: %s\n", ex.what()); + } + }, + []() { printf("OnCompleted\n"); }); + printf("//! [timeout sample]\n"); +} |