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... >
 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...
 

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
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
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

#define RXCPP_OPERATORS_RX_WINDOW_TOGGLE_HPP