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

Function main

src/examples/rpp/doxygen/combine_latest.cpp:14–39  ·  view source on GitHub ↗

* @example combine_latest.cpp **/

Source from the content-addressed store, hash-verified

12 * @example combine_latest.cpp
13 **/
14int main()
15{
16 //! [combine_latest]
17 rpp::source::just(rpp::schedulers::current_thread{}, 1, 2, 3) // source 1
18 | rpp::ops::combine_latest(rpp::source::just(rpp::schedulers::current_thread{}, 4, 5, 6)) // source 2
19 | rpp::ops::subscribe([](const std::tuple<int, int>& v) { std::cout << "-" << v; },
20 [](const std::exception_ptr&) {},
21 []() { std::cout << "-|" << std::endl; });
22 // source 1: -1---2---3-|
23 // source 2: -4---5---6-| (note that source 2 is subscribed earlier than source 1)
24 // Output : -{1,4}-{1,5}-{2,5}-{2,6}-{3,6}}-|
25 //! [combine_latest]
26
27 //! [combine_latest custom combiner]
28 rpp::source::just(1, 2, 3) // source 1
29 | rpp::ops::combine_latest([](int left, int right) { return left + right; }, // custom combiner
30 rpp::source::just(4, 5, 6)) // source 2
31 | rpp::ops::subscribe([](int v) { std::cout << "-" << v; },
32 [](const std::exception_ptr&) {},
33 []() { std::cout << "-|" << std::endl; });
34 // source 1: -1---2---3-|
35 // source 2: -4---5---6-| (note that source 2 is subscribed earlier than source 1)
36 // Output : -5-6-7-8-9-|
37 //! [combine_latest custom combiner]
38 return 0;
39}

Callers

nothing calls this directly

Calls 3

justFunction · 0.85
combine_latestFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected