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

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

◆ RXCPP_OPERATORS_RX_TAP_HPP

#define RXCPP_OPERATORS_RX_TAP_HPP
rxcpp::operators::concat
auto concat(AN &&... an) -> operator_factory< concat_tag, AN... >
Definition: rx-concat.hpp:235
rxcpp::sources::range
auto range(T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> observable< T, detail::range< T, identity_one_worker >>
Definition: rx-range.hpp:119
rxcpp::operators::tap
auto tap(AN &&... an) -> operator_factory< tap_tag, AN... >
Definition: rx-tap.hpp:121
cpplinq::from
linq_driver< iter_cursor< typename util::container_traits< TContainer >::iterator > > from(TContainer &c)
Definition: linq.hpp:556
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::util::what
std::string what(std::exception_ptr ep)
Definition: rx-util.hpp:544
rxcpp::observable
a source of values. subscribe or use one of the operator methods that return a new observable,...
Definition: rx-observable.hpp:478