ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
filter.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main() // NOLINT(bugprone-exception-escape)
{
rpp::source::just(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
| rpp::operators::filter([](int v) { return v % 2 == 0; })
| rpp::operators::subscribe([](int v) { std::cout << v << " "; });
// Output: 0 2 4 6 8
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 filter(Fn &&predicate)
Emit only those items from an Observable that satisfies a provided predicate.
Definition filter.hpp:91
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226