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 | Variables
rx-finally.hpp File Reference

Add a new action at the end of the new observable that is returned. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-finally.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< finally_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_FINALLY_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::finally (AN &&...an) -> operator_factory< final ly_tag
 Add a new action at the end of the new observable that is returned. More...
 

Variables

auto rxcpp::operators::AN
 

Detailed Description

Add a new action at the end of the new observable that is returned.

Template Parameters
LastCallthe type of the action function
Parameters
lcthe action function
Returns
Observable that emits the same items as the source observable, then invokes the given action.
Sample Code
auto values = rxcpp::observable<>::range(1, 3).
finally([](){
printf("The final action\n");
});
values.
[](int v){printf("OnNext: %d\n", v);},
[](){printf("OnCompleted\n");});
OnNext: 1
OnNext: 2
OnNext: 3
OnCompleted
The final action
If the source observable generates an error, the final action is still being called:
auto values = rxcpp::observable<>::range(1, 3).
concat(rxcpp::observable<>::error<int>(std::runtime_error("Error from source"))).
finally([](){
printf("The final action\n");
});
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: 3
OnError: Error from source
The final action

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_FINALLY_HPP