blob: 7600b94fad25a47d42508dc7d20d64008645c278 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "rxcpp/rx.hpp"
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
SCENARIO("error sample"){
printf("//! [error sample]\n");
auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source"));
values.
subscribe(
[](int v){printf("OnNext: %d\n", v);},
[](rxcpp::error_ptr ep){
printf("OnError: %s\n", rxu::what(ep));
},
[](){printf("OnCompleted\n");});
printf("//! [error sample]\n");
}
SCENARIO("threaded error sample"){
printf("//! [threaded error sample]\n");
auto values = rxcpp::observable<>::error<int>(std::runtime_error("Error from source"), rxcpp::observe_on_event_loop());
values.
as_blocking().
subscribe(
[](int v){printf("OnNext: %d\n", v);},
[](rxcpp::error_ptr ep){
printf("OnError: %s\n", rxu::what(ep));
},
[](){printf("OnCompleted\n");});
printf("//! [threaded error sample]\n");
}
|