* @example retry.cpp **/
| 7 | * @example retry.cpp |
| 8 | **/ |
| 9 | int main() |
| 10 | { |
| 11 | //! [retry] |
| 12 | rpp::source::concat(rpp::source::just(1, 2, 3), rpp::source::error<int>({})) |
| 13 | | rpp::operators::retry(2) |
| 14 | | rpp::operators::subscribe([](int v) { std::cout << v << " "; }, |
| 15 | [](const std::exception_ptr&) { std::cout << "error" << std::endl; }, |
| 16 | []() { std::cout << "completed" << std::endl; }); |
| 17 | // Output: 1 2 3 1 2 3 1 2 3 error |
| 18 | //! [retry] |
| 19 | |
| 20 | //! [retry_infinitely] |
| 21 | rpp::source::concat(rpp::source::just(1, 2, 3), rpp::source::error<int>({})) |
| 22 | | rpp::operators::retry() |
| 23 | | rpp::operators::take(10) |
| 24 | | rpp::operators::subscribe([](int v) { std::cout << v << " "; }, |
| 25 | [](const std::exception_ptr&) { std::cout << "error" << std::endl; }, |
| 26 | []() { std::cout << "completed" << std::endl; }); |
| 27 | // Output: 1 2 3 1 2 3 1 2 3 1 completed |
| 28 | //! [retry_infinitely] |
| 29 | return 0; |
| 30 | } |