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

inspect calls to on_next, on_error and on_completed. More...

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

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_TAP_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::tap (AN &&...an) -> operator_factory< tap_tag, AN... >
 inspect calls to on_next, on_error and on_completed. More...
 

Detailed Description

inspect calls to on_next, on_error and on_completed.

Template Parameters
MakeObserverArgN...these args are passed to make_observer.
Parameters
anthese args are passed to make_observer.
Returns
Observable that emits the same items as the source observable to both the subscriber and the observer.
Note
If an on_error method is not supplied the observer will ignore errors rather than call std::terminate()
Sample Code
auto values = rxcpp::observable<>::range(1, 3).
tap(
[](int v){printf("Tap - OnNext: %d\n", v);},
[](){printf("Tap - OnCompleted\n");});
values.
[](int v){printf("Subscribe - OnNext: %d\n", v);},
[](){printf("Subscribe - OnCompleted\n");});
Tap - OnNext: 1
Subscribe - OnNext: 1
Tap - OnNext: 2
Subscribe - OnNext: 2
Tap - OnNext: 3
Subscribe - OnNext: 3
Tap - OnCompleted
Subscribe - OnCompleted
If the source observable generates an error, the observer passed to tap is called:
auto values = rxcpp::observable<>::range(1, 3).
concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source"))).
tap(
[](int v){printf("Tap - OnNext: %d\n", v);},
[](std::exception_ptr ep){
printf("Tap - OnError: %s\n", rxu::what(ep).c_str());
},
[](){printf("Tap - OnCompleted\n");});
values.
[](int v){printf("Subscribe - OnNext: %d\n", v);},
[](std::exception_ptr ep){
printf("Subscribe - OnError: %s\n", rxu::what(ep).c_str());
},
[](){printf("Subscribe - OnCompleted\n");});
Tap - OnNext: 1
Subscribe - OnNext: 1
Tap - OnNext: 2
Subscribe - OnNext: 2
Tap - OnNext: 3
Subscribe - OnNext: 3
Tap - OnError: Error from source
Subscribe - OnError: Error from source

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_TAP_HPP