ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
window_toggle.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main()
{
size_t counter{};
source
| rpp::operators::window_toggle(source, [source](int) { return source | rpp::ops::filter([](int v) { return v % 2 == 0; }); })
| rpp::operators::subscribe([&counter](const rpp::window_toggle_observable<int>& obs) {
std::cout << "New observable " << ++counter << std::endl;
obs.subscribe([counter](int v) { std::cout << counter << ": " << v << " " << std::endl; }, [counter]() { std::cout << "closing " << counter << std::endl; });
});
// Output:
// New observable 1
// 1: 1
// New observable 2
// 1: 2
// 2: 2
// closing 1
// New observable 3
// 2: 3
// 3: 3
// New observable 4
// 2: 4
// 3: 4
// 4: 4
// closing 2
// closing 3
// New observable 5
// 4: 5
// 5: 5
// closing 4
// closing 5
return 0;
}
Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_poi...
Definition current_thread.hpp:86
auto publish()
Converts ordinary observable to rpp::connectable_observable with help of inline instsantiated publish...
Definition publish.hpp:22
auto ref_count()
Forces rpp::connectable_observable to behave like common observable.
Definition ref_count.hpp:29
auto just(const TScheduler &scheduler, T &&item, Ts &&... items)
Creates rpp::observable that emits a particular items and completes.
Definition from.hpp:201
auto filter(Fn &&predicate)
Emit only those items from an Observable that satisfies a provided predicate.
Definition filter.hpp:91
auto window_toggle(TOpeningsObservable &&openings, TClosingsSelectorFn &&closings_selector)
Subdivide original observable into sub-observables (window observables) and emit sub-observables of i...
Definition window_toggle.hpp:236
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226