ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
reduce.cpp
#include <rpp/rpp.hpp>
#include <iostream>
#include <string>
int main()
{
| rpp::operators::reduce(std::string{}, [](std::string&& seed, int v) { return std::move(seed) + std::to_string(v) + ","; })
| rpp::operators::subscribe([](const std::string& v) { std::cout << v << std::endl; });
// Output: 1,2,3,
| rpp::operators::reduce(std::plus<int>{})
| rpp::operators::subscribe([](int v) { std::cout << v << std::endl; });
// Output: 6
return 0;
}
auto reduce(Seed &&seed, Accumulator &&accumulator)
Apply a function to each item emitted by an Observable, sequentially, and emit the final value.
Definition reduce.hpp:143
auto just(const TScheduler &scheduler, T &&item, Ts &&... items)
Creates rpp::observable that emits a particular items and completes.
Definition from.hpp:201
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226