ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
switch_map.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main()
{
rpp::source::just(1, 2, 3)
.switch_map([](int val) {
if (val == 1)
return rpp::source::never<int>()
sub.get_subscription().add([&]() {
std::cout << "x-"; // x is notation for unsubscribed
});
return sub;
})
.as_dynamic();
return rpp::source::from_iterable(std::vector{val, val})
.as_dynamic();
})
.subscribe([](int v) { std::cout << v << "-"; });
// Output: x-2-2-3-3-
return 0;
}
subscriber which uses dynamic_observer<T> to hide original callbacks
Definition: dynamic_subscriber.hpp:24