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.hpp File Reference

Return an observable that emits connected, non-overlapping windows, each containing at most count items from the source observable. If the skip parameter is set, return an observable that emits windows every skip items containing at most count items from the source observable. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-window.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_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_WINDOW_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::window (AN &&...an) -> operator_factory< window_tag, AN... >
 Return an observable that emits connected, non-overlapping windows, each containing at most count items from the source observable. If the skip parameter is set, return an observable that emits windows every skip items containing at most count items from the source observable. More...
 

Detailed Description

Return an observable that emits connected, non-overlapping windows, each containing at most count items from the source observable. If the skip parameter is set, return an observable that emits windows every skip items containing at most count items from the source observable.

Parameters
countthe maximum size of each window before it should be completed
skiphow many items need to be skipped before starting a new window
Returns
Observable that emits connected, non-overlapping windows, each containing at most count items from the source observable. If the skip parameter is set, return an Observable that emits windows every skip items containing at most count items from the source observable.
Sample Code
int counter = 0;
auto values = rxcpp::observable<>::range(1, 7).window(2, 3);
values.
[&counter](rxcpp::observable<int> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](int v){printf("[window %d] OnNext: %d\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 0] OnCompleted
[window 1] Create window
[window 1] OnNext: 4
[window 1] OnNext: 5
[window 1] OnCompleted
[window 2] Create window
[window 2] OnNext: 7
[window 2] OnCompleted
Sample Code
int counter = 0;
auto values = rxcpp::observable<>::range(1, 5).window(2);
values.
[&counter](rxcpp::observable<int> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](int v){printf("[window %d] OnNext: %d\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 0] OnCompleted
[window 1] Create window
[window 1] OnNext: 3
[window 1] OnNext: 4
[window 1] OnCompleted
[window 2] Create window
[window 2] OnNext: 5
[window 2] OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_WINDOW_HPP