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

Function main

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

* @example repeat.cpp **/

Source from the content-addressed store, hash-verified

7 * @example repeat.cpp
8 **/
9int main()
10{
11 //! [repeat]
12 rpp::source::just(1, 2, 3)
13 | rpp::operators::repeat(2)
14 | rpp::operators::subscribe([](int v) { std::cout << v << " "; },
15 [](const std::exception_ptr&) {},
16 []() { std::cout << "completed" << std::endl; });
17 // Output: 1 2 3 1 2 3 completed
18 //! [repeat]
19
20 //! [repeat_infinitely]
21 rpp::source::just(1, 2, 3)
22 | rpp::operators::repeat()
23 | rpp::operators::take(10)
24 | rpp::operators::subscribe([](int v) { std::cout << v << " "; },
25 [](const std::exception_ptr&) {},
26 []() {
27 std::cout << "completed" << std::endl;
28 });
29 // Output: 1 2 3 1 2 3 1 2 3 1 completed
30 //! [repeat_infinitely]
31 return 0;
32}

Callers

nothing calls this directly

Calls 4

justFunction · 0.85
repeatFunction · 0.85
subscribeFunction · 0.85
takeFunction · 0.85

Tested by

no test coverage detected