June 2018
Intermediate to advanced
348 pages
8h 45m
English
So far, in this chapter, we have seen that the source sequence in RxCpp can terminate gracefully after throwing exceptions. The finally() Operator is useful when we are using external resources, or when there's a need to free up some resources allocated in some other parts of the program. As we know, there are millions of lines of code that are already written for building various systems in C++, and it is highly likely that we need to handle resource management when using legacy external dependencies. This is a place where finally() comes in handy in RxCpp:
//------- Finally.cpp #include "rxcpp/rx.hpp" int main() { auto values = rxcpp::observable<>::range(1, 3). concat(rxcpp::observable<>:: error<int>(std::runtime_error("Error ...