ReactivePlusPlus
ReactiveX implementation for C++20
|
Transforming operators are operators that transform items provided by observable. More...
Functions | |
auto | rpp::operators::buffer (size_t count) |
Periodically gather emissions emitted by an original Observable into bundles and emit these bundles rather than emitting the items one at a time. | |
template<typename Fn> requires (!utils::is_not_template_callable<Fn> || rpp::constraint::observable<std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>) | |
auto | rpp::operators::flat_map (Fn &&callable) |
Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable. | |
template<typename KeySelector, typename ValueSelector = std::identity, typename KeyComparator = rpp::utils::less> requires ( (!utils::is_not_template_callable<KeySelector> || !std::same_as<void, std::invoke_result_t<KeySelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<ValueSelector> || !std::same_as<void, std::invoke_result_t<ValueSelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<KeyComparator> || std::strict_weak_order<KeyComparator, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>)) | |
auto | rpp::operators::group_by (KeySelector &&key_selector, ValueSelector &&value_selector, KeyComparator &&comparator) |
Divide original observable into multiple observables where each new observable emits some group of values from original observable. | |
template<typename Fn> requires (!utils::is_not_template_callable<Fn> || !std::same_as<void, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>) | |
auto | rpp::operators::map (Fn &&callable) |
Transforms the items emitted by an Observable via applying a function to each item and emitting result. | |
template<typename InitialValue, typename Fn> requires (!utils::is_not_template_callable<Fn> || std::same_as<std::decay_t<InitialValue>, std::invoke_result_t<Fn, std::decay_t<InitialValue> &&, rpp::utils::convertible_to_any>>) | |
auto | rpp::operators::scan (InitialValue &&initial_value, Fn &&accumulator) |
Apply accumulator function for each emission from observable and result of accumulator from previous step and emit (and cache) resulting value. | |
template<typename Fn> | |
auto | rpp::operators::scan (Fn &&accumulator) |
Apply accumulator function for each emission from observable and result of accumulator from previous step and emit (and cache) resulting value. | |
auto | rpp::operators::window (size_t count) |
Subdivide original observable into sub-observables (window observables) and emit sub-observables of items instead of original items. | |
template<rpp::constraint::observable TOpeningsObservable, typename TClosingsSelectorFn> requires rpp::constraint::observable<std::invoke_result_t<TClosingsSelectorFn, rpp::utils::extract_observable_type_t<TOpeningsObservable>>> | |
auto | rpp::operators::window_toggle (TOpeningsObservable &&openings, TClosingsSelectorFn &&closings_selector) |
Subdivide original observable into sub-observables (window observables) and emit sub-observables of items instead of original items. | |
Transforming operators are operators that transform items provided by observable.
|
inline |
Periodically gather emissions emitted by an original Observable into bundles and emit these bundles rather than emitting the items one at a time.
The resulting bundle is std::vector<Type>
of requested size. Actually it is similar to window()
operator, but it emits vectors instead of observables.
count | number of items being bundled. |
#include <rpp/operators/buffer.hpp>
auto rpp::operators::flat_map | ( | Fn && | callable | ) |
Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable.
Actually it makes map(callable)
and then merge
.
Note that flat_map merges the emissions of these Observables, so that they may interleave.
callable | function that returns an observable for each item emitted by the source observable. |
#include <rpp/operators/flat_map.hpp>
auto rpp::operators::group_by | ( | KeySelector && | key_selector, |
ValueSelector && | value_selector, | ||
KeyComparator && | comparator ) |
Divide original observable into multiple observables where each new observable emits some group of values from original observable.
Actually this operator applies key_selector
to emission to obtain key, place rpp::grouped_observable to map with corresponding map and then send observable with this key (if not yet). Original values emitted via this grouped_observables
key_selector | Function which determines key for provided item |
value_selector | Function which determines value to be emitted to grouped observable |
comparator | Function to provide strict_weak_order between key types |
#include <rpp/operators/group_by.hpp>
auto rpp::operators::map | ( | Fn && | callable | ) |
Transforms the items emitted by an Observable via applying a function to each item and emitting result.
Actually this operator just applies callable to each obtained emission and emit resulting value
callable | is callable used to provide this transformation. Should accept Type of original observable and return type for new observable |
#include <rpp/operators/map.hpp>
auto rpp::operators::scan | ( | Fn && | accumulator | ) |
Apply accumulator function for each emission from observable and result of accumulator from previous step and emit (and cache) resulting value.
Actually this operator applies provided accumulator function to seed and new emission, emits resulting value and updates seed value for next emission
accumulator | function which accepts seed value and new value from observable and return new value of seed. Can accept seed by move-reference. |
#include <rpp/operators/scan.hpp>
auto rpp::operators::scan | ( | InitialValue && | initial_value, |
Fn && | accumulator ) |
Apply accumulator function for each emission from observable and result of accumulator from previous step and emit (and cache) resulting value.
Actually this operator applies provided accumulator function to seed and new emission, emits resulting value and updates seed value for next emission
initial_value | initial value for seed which would be sent during subscription and applied for first value from observable. Then it will be replaced with result and etc. |
accumulator | function which accepts seed value and new value from observable and return new value of seed. Can accept seed by move-reference. |
#include <rpp/operators/scan.hpp>
|
inline |
Subdivide original observable into sub-observables (window observables) and emit sub-observables of items instead of original items.
Actually it is similar to buffer
but it emits observable instead of container.
count | amount of items which every observable would have |
#include <rpp/operators/window.hpp>
auto rpp::operators::window_toggle | ( | TOpeningsObservable && | openings, |
TClosingsSelectorFn && | closings_selector ) |
Subdivide original observable into sub-observables (window observables) and emit sub-observables of items instead of original items.
Values from openings
observable used to specify moment when new window will be opened. closings_selector
is used to obtain observable to specify moment when new window will be closed.
Actually it is similar to buffer
but it emits observable instead of container.
openings | is observable which emissions used to start new window |
closings_selector | is function which returns observable which emission/completion means closing of opened window |
#include <rpp/operators/window.hpp>