ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
buffer.cpp
#include <rpp/rpp.hpp>
#include <iostream>
std::ostream& operator<<(std::ostream& out, const std::vector<int>& list)
{
out << "{";
auto size = list.size();
for (size_t i = 0; i < size; ++i)
{
out << list.at(i);
if (i < size - 1)
{
out << ",";
}
}
out << "}";
return out;
}
int main()
{
// The stream that uses rvalue overloads for operators
rpp::source::just(1, 2, 3, 4, 5)
| rpp::ops::buffer(2)
| rpp::ops::subscribe(
[](const std::vector<int>& v) { std::cout << v << "-"; },
[](const std::exception_ptr&) {},
[]() { std::cout << "|" << std::endl; });
// Source: -1-2-3-4-5--|
// Output: {1,2}-{3,4}-{5}-|
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