ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
scan.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main()
{
| rpp::operators::scan(10, std::plus<int>{})
| rpp::operators::subscribe([](int v) { std::cout << v << std::endl; });
// Output: 10 11 13 16
| rpp::operators::scan(std::vector<int>{}, [](std::vector<int>&& seed, int new_value) {
seed.push_back(new_value);
return std::move(seed);
})
| rpp::operators::subscribe([](const std::vector<int>& v) {
std::cout << "vector: ";
for (int val : v)
std::cout << val << " ";
std::cout << std::endl;
});
// Output: vector:
// vector: 1
// vector: 1 2
// vector: 1 2 3
| rpp::operators::scan(std::plus<int>{})
| rpp::operators::subscribe([](int v) { std::cout << v << std::endl; });
// Output: 1 3 6
return 0;
}
auto just(const TScheduler &scheduler, T &&item, Ts &&... items)
Creates rpp::observable that emits a particular items and completes.
Definition from.hpp:201
auto scan(InitialValue &&initial_value, Fn &&accumulator)
Apply accumulator function for each emission from observable and result of accumulator from previous ...
Definition scan.hpp:151
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226