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

If the source Observable terminates without emitting any items, emits items from a backup Observable. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-switch_if_empty.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< switch_if_empty_tag >
 
struct  rxcpp::member_overload< default_if_empty_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_SWITCH_IF_EMPTY_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::switch_if_empty (AN &&...an) -> operator_factory< switch_if_empty_tag, AN... >
 If the source Observable terminates without emitting any items, emits items from a backup Observable. More...
 
template<class... AN>
auto rxcpp::operators::default_if_empty (AN &&...an) -> operator_factory< default_if_empty_tag, AN... >
 If the source Observable terminates without emitting any items, emits a default item and completes. More...
 

Detailed Description

If the source Observable terminates without emitting any items, emits items from a backup Observable.

Template Parameters
BackupSourcethe type of the backup observable.
Parameters
ta backup observable that is used if the source observable is empty.
Returns
Observable that emits items from a backup observable if the source observable is empty.
Sample Code
auto values = rxcpp::observable<>::empty<int>()
values.subscribe(
[](int v) { printf("OnNext: %d\n", v); },
[]() { printf("OnCompleted\n"); } );
OnNext: 1
OnNext: 2
OnNext: 3
OnNext: 4
OnNext: 5
OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_SWITCH_IF_EMPTY_HPP