ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
distinct_until_changed.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main()
{
rpp::source::just(1, 1, 2, 2, 3, 2, 1)
| rpp::operators::subscribe([](int val) { std::cout << val << " "; });
// Output: 1 2 3 2 1
std::cout << std::endl;
rpp::source::just(1, 1, 2, 2, 3, 2, 1)
| rpp::operators::distinct_until_changed([](int left, int right) { return left != right; })
| rpp::operators::subscribe([](int val) { std::cout << val << " "; });
// Output: 1 1 1
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 distinct_until_changed(EqualityFn &&equality_fn)
Suppress consecutive duplicates of emissions from original observable.
Definition distinct_until_changed.hpp:97
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226