MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rpp/doxygen/take_until.cpp:9–33  ·  view source on GitHub ↗

* @example take_until.cpp **/

Source from the content-addressed store, hash-verified

7 * @example take_until.cpp
8 **/
9int main()
10{
11 //! [take_until]
12 rpp::source::interval(std::chrono::seconds{1}, rpp::schedulers::current_thread{})
13 | rpp::ops::take_until(rpp::source::interval(std::chrono::seconds{5}, rpp::schedulers::current_thread{}))
14 | rpp::ops::subscribe([](int v) { std::cout << "-" << v; },
15 [](const std::exception_ptr&) { std::cout << "-x" << std::endl; },
16 []() { std::cout << "-|" << std::endl; });
17 // source 1: -0-1-2-3-4-5-6-7- --
18 // source 2: ---------0---------1- --
19 // Output : -0-1-2-3-|
20 //! [take_until]
21
22 //! [terminate]
23 rpp::source::never<int>()
24 | rpp::ops::take_until(rpp::source::error<bool>(std::make_exception_ptr(std::runtime_error{""})))
25 | rpp::ops::subscribe([](int v) { std::cout << "-" << v; },
26 [](const std::exception_ptr&) { std::cout << "-x" << std::endl; },
27 []() { std::cout << "-|" << std::endl; });
28 // source 1: -
29 // source 2: -x
30 // Output : -x
31 //! [terminate]
32 return 0;
33}

Callers

nothing calls this directly

Calls 3

intervalFunction · 0.85
take_untilFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected