diff options
author | Grigoriy Chudnov <g.chudnov@gmail.com> | 2016-03-29 11:31:06 +0300 |
---|---|---|
committer | Grigoriy Chudnov <g.chudnov@gmail.com> | 2016-03-29 11:31:06 +0300 |
commit | 76be7e2cda2e95257dd25d392050e616f23602a0 (patch) | |
tree | af3ae5b803a5761ff5eec681b163ea2398298969 /Rx/v2/examples | |
parent | 66c62ee6d71e48870533f89286a1dee704699efe (diff) | |
download | RxCpp-76be7e2cda2e95257dd25d392050e616f23602a0.tar.gz |
add samples for contains and exists via operator call syntax
Diffstat (limited to 'Rx/v2/examples')
-rw-r--r-- | Rx/v2/examples/doxygen/contains.cpp | 21 | ||||
-rw-r--r-- | Rx/v2/examples/doxygen/exists.cpp | 21 |
2 files changed, 36 insertions, 6 deletions
diff --git a/Rx/v2/examples/doxygen/contains.cpp b/Rx/v2/examples/doxygen/contains.cpp index 9bc551a..6e59649 100644 --- a/Rx/v2/examples/doxygen/contains.cpp +++ b/Rx/v2/examples/doxygen/contains.cpp @@ -3,12 +3,27 @@ #include "rxcpp/rx-test.hpp" #include "catch.hpp" -SCENARIO("contains sample"){ +SCENARIO("contains sample") { printf("//! [contains sample]\n"); auto values = rxcpp::observable<>::from(1, 2, 3, 4, 5).contains(3); values. subscribe( - [](bool v){ printf("OnNext: %s\n", v ? "true" : "false"); }, - [](){ printf("OnCompleted\n"); }); + [](bool v) { printf("OnNext: %s\n", v ? "true" : "false"); }, + []() { printf("OnCompleted\n"); }); printf("//! [contains sample]\n"); +} + +SCENARIO("contains - operator syntax sample") { + using namespace rxcpp; + using namespace rxcpp::sources; + using namespace rxcpp::operators; + + printf("//! [contains - operator syntax sample]\n"); + auto values = range(1, 10) + | contains(2); + values. + subscribe( + [](bool v) { printf("OnNext: %s\n", v ? "true" : "false"); }, + []() { printf("OnCompleted\n"); }); + printf("//! [contains - operator syntax sample]\n"); }
\ No newline at end of file diff --git a/Rx/v2/examples/doxygen/exists.cpp b/Rx/v2/examples/doxygen/exists.cpp index a2dd283..6e4d249 100644 --- a/Rx/v2/examples/doxygen/exists.cpp +++ b/Rx/v2/examples/doxygen/exists.cpp @@ -3,12 +3,27 @@ #include "rxcpp/rx-test.hpp" #include "catch.hpp" -SCENARIO("exists sample"){ +SCENARIO("exists sample") { printf("//! [exists sample]\n"); auto values = rxcpp::observable<>::from(1, 2, 3, 4, 5).exists([](int n) { return n > 3; }); values. subscribe( - [](bool v){ printf("OnNext: %s\n", v ? "true" : "false"); }, - [](){ printf("OnCompleted\n"); }); + [](bool v) { printf("OnNext: %s\n", v ? "true" : "false"); }, + []() { printf("OnCompleted\n"); }); printf("//! [exists sample]\n"); +} + +SCENARIO("exists - operator syntax sample") { + using namespace rxcpp; + using namespace rxcpp::sources; + using namespace rxcpp::operators; + + printf("//! [exists - operator syntax sample]\n"); + auto values = range(1, 10) + | exists([](int n) { return n == 1; }); + values. + subscribe( + [](bool v) { printf("OnNext: %s\n", v ? "true" : "false"); }, + []() { printf("OnCompleted\n"); }); + printf("//! [exists - operator syntax sample]\n"); }
\ No newline at end of file |