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

Retry this observable for the given number of times. More...

#include "../rx-includes.hpp"
#include "rx-retry-repeat-common.hpp"
Include dependency graph for rx-retry.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< retry_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_RETRY_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::retry (AN &&...an) -> operator_factory< retry_tag, AN... >
 Retry this observable for the given number of times. More...
 

Detailed Description

Retry this observable for the given number of times.

Template Parameters
Countthe type of the counter (optional)
Parameters
tthe total number of tries (optional), i.e. retry(2) means one normal try, before an error occurs, and one retry. If not specified, infinitely retries the source observable. Specifying 0 returns immediately without subscribing
Returns
An observable that mirrors the source observable, resubscribing to it if it calls on_error up to a specified number of retries.
Sample Code
auto source = rxcpp::observable<>::from(1, 2).
concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source")));
auto values = source.retry(3);
values.
[](int v){printf("OnNext: %d\n", v);},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 1
OnNext: 2
OnNext: 1
OnNext: 2
OnError: Error from source

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_RETRY_HPP