summaryrefslogtreecommitdiff
path: root/Rx/v2/examples/doxygen/subscribe.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2022-09-01 14:59:27 +0000
committerElliott Hughes <enh@google.com>2022-09-01 15:00:13 +0000
commita6661d2cf339b71de3e25f80fb927e029468c603 (patch)
treec0b1aac3621dd301e9fb7add9170d8879cc97cbe /Rx/v2/examples/doxygen/subscribe.cpp
parentde986f59e99bd585280a061f545150ee1268f012 (diff)
downloadRxCpp-a6661d2cf339b71de3e25f80fb927e029468c603.tar.gz
Remove RxCpp, which is no longer used.HEADmastermain
Do not necromance this without going through the go/android-3p process again. Test: treehugger Change-Id: Id813d74d7d2597e0636b925430117c94bea3fa5a
Diffstat (limited to 'Rx/v2/examples/doxygen/subscribe.cpp')
-rw-r--r--Rx/v2/examples/doxygen/subscribe.cpp101
1 files changed, 0 insertions, 101 deletions
diff --git a/Rx/v2/examples/doxygen/subscribe.cpp b/Rx/v2/examples/doxygen/subscribe.cpp
deleted file mode 100644
index e7c3435..0000000
--- a/Rx/v2/examples/doxygen/subscribe.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "rxcpp/rx.hpp"
-
-#include "rxcpp/rx-test.hpp"
-#include "catch.hpp"
-
-SCENARIO("subscribe by subscriber"){
- printf("//! [subscribe by subscriber]\n");
- auto subscriber = rxcpp::make_subscriber<int>(
- [](int v){printf("OnNext: %d\n", v);},
- [](){printf("OnCompleted\n");});
- auto values = rxcpp::observable<>::range(1, 3);
- values.subscribe(subscriber);
- printf("//! [subscribe by subscriber]\n");
-}
-
-SCENARIO("subscribe by observer"){
- printf("//! [subscribe by observer]\n");
- auto subscriber = rxcpp::make_subscriber<int>(
- [](int v){printf("OnNext: %d\n", v);},
- [](){printf("OnCompleted\n");});
- auto values1 = rxcpp::observable<>::range(1, 3);
- auto values2 = rxcpp::observable<>::range(4, 6);
- values1.subscribe(subscriber.get_observer());
- values2.subscribe(subscriber.get_observer());
- printf("//! [subscribe by observer]\n");
-}
-
-SCENARIO("subscribe by on_next"){
- printf("//! [subscribe by on_next]\n");
- auto values = rxcpp::observable<>::range(1, 3);
- values.subscribe(
- [](int v){printf("OnNext: %d\n", v);});
- printf("//! [subscribe by on_next]\n");
-}
-
-SCENARIO("subscribe by on_next and on_error"){
- printf("//! [subscribe by on_next and on_error]\n");
- auto values = rxcpp::observable<>::range(1, 3).
- concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source")));
- values.subscribe(
- [](int v){printf("OnNext: %d\n", v);},
- [](std::exception_ptr ep){
- try {std::rethrow_exception(ep);}
- catch (const std::exception& ex) {
- printf("OnError: %s\n", ex.what());
- }
- });
- printf("//! [subscribe by on_next and on_error]\n");
-}
-
-SCENARIO("subscribe by on_next and on_completed"){
- printf("//! [subscribe by on_next and on_completed]\n");
- auto values = rxcpp::observable<>::range(1, 3);
- values.subscribe(
- [](int v){printf("OnNext: %d\n", v);},
- [](){printf("OnCompleted\n");});
- printf("//! [subscribe by on_next and on_completed]\n");
-}
-
-SCENARIO("subscribe by subscription, on_next, and on_completed"){
- printf("//! [subscribe by subscription, on_next, and on_completed]\n");
- auto subscription = rxcpp::composite_subscription();
- auto values = rxcpp::observable<>::range(1, 5);
- values.subscribe(
- subscription,
- [&subscription](int v){
- printf("OnNext: %d\n", v);
- if (v == 3)
- subscription.unsubscribe();
- },
- [](){printf("OnCompleted\n");});
- printf("//! [subscribe by subscription, on_next, and on_completed]\n");
-}
-
-SCENARIO("subscribe by on_next, on_error, and on_completed"){
- printf("//! [subscribe by on_next, on_error, and on_completed]\n");
- auto values = rxcpp::observable<>::range(1, 3).
- concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source")));
- values.subscribe(
- [](int v){printf("OnNext: %d\n", v);},
- [](std::exception_ptr ep){
- try {std::rethrow_exception(ep);}
- catch (const std::exception& ex) {
- printf("OnError: %s\n", ex.what());
- }
- },
- [](){printf("OnCompleted\n");});
- printf("//! [subscribe by on_next, on_error, and on_completed]\n");
-}
-
-SCENARIO("subscribe unsubscribe"){
- printf("//! [subscribe unsubscribe]\n");
- auto values = rxcpp::observable<>::range(1, 3).
- concat(rxcpp::observable<>::never<int>()).
- finally([](){printf("The final action\n");});
- auto subscription = values.subscribe(
- [](int v){printf("OnNext: %d\n", v);},
- [](){printf("OnCompleted\n");});
- subscription.unsubscribe();
- printf("//! [subscribe unsubscribe]\n");
-}