ReactivePlusPlus
ReactiveX implementation for C++20
Toggle main menu visibility
Loading...
Searching...
No Matches
retry.cpp
#include <rpp/rpp.hpp>
#include <exception>
#include <iostream>
int
main()
{
rpp::source::concat
(
rpp::source::just
(1, 2, 3),
rpp::source::error<int>
({}))
|
rpp::operators::retry
(2)
|
rpp::operators::subscribe
([](
int
v) { std::cout << v <<
" "
; },
[](
const
std::exception_ptr&) { std::cout <<
"error"
<< std::endl; },
[]() { std::cout <<
"completed"
<< std::endl; });
// Output: 1 2 3 1 2 3 1 2 3 error
rpp::source::concat
(
rpp::source::just
(1, 2, 3),
rpp::source::error<int>
({}))
|
rpp::operators::retry
()
|
rpp::operators::take
(10)
|
rpp::operators::subscribe
([](
int
v) { std::cout << v <<
" "
; },
[](
const
std::exception_ptr&) { std::cout <<
"error"
<< std::endl; },
[]() { std::cout <<
"completed"
<< std::endl; });
// Output: 1 2 3 1 2 3 1 2 3 1 completed
return
0;
}
rpp::source::just
auto just(const TScheduler &scheduler, T &&item, Ts &&... items)
Creates rpp::observable that emits a particular items and completes.
Definition
from.hpp:201
rpp::source::error
auto error(std::exception_ptr err)
Creates rpp::observable that emits no items and terminates with an error.
Definition
error.hpp:49
rpp::source::concat
auto concat(TObservable &&obs, TObservables &&... others)
Make observable which would merge emissions from underlying observables but without overlapping (curr...
Definition
concat.hpp:168
rpp::operators::retry
auto retry(size_t count)
The retry operator attempts to resubscribe to the observable when an error occurs,...
Definition
retry.hpp:149
rpp::operators::take
auto take(size_t count)
Emit only first count items provided by observable, then send on_completed.
Definition
take.hpp:92
rpp::operators::subscribe
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition
subscribe.hpp:226
Generated by
1.17.0