RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
Classes | Namespaces | Macros | Functions
rx-window_toggle.hpp File Reference

Return an observable that emits observables every period time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-window_toggle.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rxcpp::member_overload< window_toggle_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_WINDOW_TOGGLE_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::window_toggle (AN &&... an) -> operator_factory< window_toggle_tag, AN... >
 

Detailed Description

Return an observable that emits observables every period time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler.

Template Parameters
Openingsobservable<OT>
ClosingSelectora function of type observable<CT>(OT)
Coordinationthe type of the scheduler (optional).
Parameters
openseach value from this observable opens a new window.
closesthis function is called for each opened window and returns an observable. the first value from the returned observable will close the window.
coordinationthe scheduler for the windows (optional).
Returns
Observable that emits an observable for each opened window.
Sample Code\n
int counter = 0;
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
rxcpp::observable<>::interval(std::chrono::milliseconds(4)),
[](long){
return rxcpp::observable<>::interval(std::chrono::milliseconds(4)).skip(1);
},
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 1] Create window
[window 0] OnCompleted
[window 1] OnNext: 3
[window 1] OnNext: 4
[window 2] Create window
[window 1] OnCompleted
[window 2] OnNext: 5
[window 2] OnNext: 6
[window 3] Create window
[window 2] OnCompleted
[window 3] OnNext: 7
[window 3] OnCompleted
Sample Code\n
int counter = 0;
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
rxcpp::observable<>::interval(std::chrono::milliseconds(4)),
[](long){
return rxcpp::observable<>::interval(std::chrono::milliseconds(4)).skip(1);
});
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 1] Create window
[window 0] OnCompleted
[window 1] OnNext: 3
[window 1] OnNext: 4
[window 2] Create window
[window 1] OnCompleted
[window 2] OnNext: 5
[window 2] OnNext: 6
[window 3] Create window
[window 2] OnCompleted
[window 3] OnNext: 7
[window 3] OnCompleted

Macro Definition Documentation

◆ RXCPP_OPERATORS_RX_WINDOW_TOGGLE_HPP

#define RXCPP_OPERATORS_RX_WINDOW_TOGGLE_HPP
rxcpp::observe_on_new_thread
observe_on_one_worker observe_on_new_thread()
Definition: rx-observe_on.hpp:328
rxcpp::operators::window
auto window(AN &&... an) -> operator_factory< window_tag, AN... >
Definition: rx-window.hpp:138
rxcpp::operators::as_blocking
auto as_blocking() -> detail::blocking_factory
Definition: rx-subscribe.hpp:144
rxcpp::operators::take
auto take(AN &&... an) -> operator_factory< take_tag, AN... >
Definition: rx-take.hpp:133
rxcpp::operators::window_toggle
auto window_toggle(AN &&... an) -> operator_factory< window_toggle_tag, AN... >
Definition: rx-window_toggle.hpp:275
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::sources::interval
auto interval(Duration period) -> typename std::enable_if< detail::defer_interval< Duration, identity_one_worker >::value, typename detail::defer_interval< Duration, identity_one_worker >::observable_type >::type
Definition: rx-interval.hpp:113
rxcpp::observable::subscribe
auto subscribe(ArgN &&... an) const -> composite_subscription
Definition: rx-observable.hpp:637
rxcpp::observable
a source of values. subscribe or use one of the operator methods that return a new observable,...
Definition: rx-observable.hpp:478